This solution requires me to run Python on the same machine as the process I am trying to terminate.
However, I'm running Python locally and have the process running over SSH in Terminal. How do I send the terminate command in this situation?
This solution requires me to run Python on the same machine as the process I am trying to terminate.
However, I'm running Python locally and have the process running over SSH in Terminal. How do I send the terminate command in this situation?
SSH using pexpect
after setting up ssh-keygen
with the server so that it doesn't require a password from your machine:
import pexpect
ssh_command = 'ssh user@your.server.com'
child = pexpect.spawn(ssh_command)
default_prompt = 'user@server:~/# '
child.expect(default_prompt)
kill_command = 'killall process_name'
child.sendline(kill_command)
If you don't use ssh-keygen
, you will need to work your password login into the pexpect
script before the default_prompt
line.
Just attach this script to a hotkey (e.g. ctrl+alt+c
) using Alfred.