0

I can ssh to a RPi 4 from Windows 10 and start a remote Python script, but the output of the script appears on the Windows console.

Tried using nohup to be able to close the Windows console without interrupting the script, but didn't work (no warnings).

(AHK) run %ComSpec% /c ssh <host> "nohup python3 /home/pi/this.py"

Tried tmux, but using a Windows AHK script to open a ssh connection then create a tmux session gives a warning that tmux file or directory wasn't found (/usr/bin/tmux, same directory as /usr/bin/python).

I can manually connect via ssh and execute tmux without issues.

stocky
  • 13
  • 5
  • You listed a lot of things that you tried... what are you actually trying/hoping to do? – JJohnston2 Jan 08 '22 at 21:27
  • I'd like to execute a remote script via ssh so it opens a console on the remote RPi (tmux) and runs independently of the OpenSSH window on the local Windows machine. Last time I tried tmux in a ssh command, it wasn't found, but it is in the same folder as python3 (/usr/bin). – stocky Jan 09 '22 at 19:58

1 Answers1

0

Screen should be able to do what you want (if I properly understand your goal).

You can start it in detached mode via screen -d -m yourcommand (taken from this answer).

I've used this to automatically start a Minecraft server in a way that let me access the console if I needed to admin anything.

  • Have you used it within a ssh command/connection? – stocky Jan 12 '22 at 00:45
  • Not interactively, typing one command at a time, but from a local script (one line). – stocky Jan 12 '22 at 01:28
  • @stocky yes, I have used it over SSH. I had a headless server at home which I would just SSH to and run `minecraft.sh`, which would check for a running MC process, and if none were found, it would launch one in a detached Screen. I could then exit that SSH session, and return to the detached Screen in later SSH sessions. – JediWombat Jan 14 '22 at 04:20
  • This is what I'm talking about: https://stackoverflow.com/questions/63399902/error-when-opening-tmux-directly-from-ssh-connection – stocky Jan 15 '22 at 12:22
  • That should work fine, but I'm not in a position to test it. Have you tried it and found it to not work? If so, what is the error or problem you're seeing? The thread to which you've linked has a fairly good answer. – JediWombat Jan 17 '22 at 22:36
  • The issue with not finding tmux was because of a server mix up. Now trying the correct syntax to send this command through ssh and inside a local script one-liner. – stocky Jan 18 '22 at 23:01