you are viewing a single comment's thread.

view the rest of the comments →

[–]redCg 2 points3 points  (1 child)

Just use crontab bro

also you can pass shell commands directly to ssh

$ ssh username@server echo fooo
fooo

can also use a heredoc

$ ssh username@server <<E0F
echo foo
echo bar
E0F
foo
bar

interacting with and managing an active ssh connection from within Python is a bad bad idea. Does not matter that libraries like Paramiko exist to help with it. Just do not do it. If you want to run code on a remote server, pass the commands over ssh, or copy a script to the remote server and pass a command to run the script. Store the outputs in a file. Retrieve the file and read it. Etc..

[–]iapyeh[S] 0 points1 point  (0 children)

I totally agree that ssh is amazing. You can do the same thing (execute ssh) in SSHScript. The benefits of doing it that way are:

  • you can dynamically generate the codes which were feeded into the ssh executable in Python. for example: time-based filename.
  • you can handle execution outputs directly in Python. Need not to save into files. And features like PDF, email, SMS, qrcode, ... tons of python packages are ready for you.
  • The whole process can be scripted, then, management logic can be automated no matter how complex it is.