SSH: execute one command then exit
I want to execute a script on a remote machine from a script. How can I do that?
I have ssh -l user -i id_rsa -fq ip command and it works.... but I want ssh to die after executing the command. Is there some way to do that? |
well -f option forces the ssh to go to background before executing the command try without it.
|
I'll give that a shot... but I sort of figured it would just dump me in a shell.
Thanks for the idea, I'll try it. |
nope, that didn't do it. :(
|
...well, it exits like it should when it runs programs such as ls, but it just hangs around when I run bash scripts on the remote computer.
At the end of the script, I run mpg123 with --repeat. |
Put the 'exit' as the last line of the script. It is running in the console and should exit the ssh session
R.O. |
Note: You may want to add
nohup mpg123 -repeat & That will start it in the background, if it doesn't already, and the nohup frees it up from the parent process, which is the ssh console. Otherwise, when the console exits, mpg123 may also exit. Add at least a sleep 3 such as nohup mpg123 -repeat & sleep 3 exit That gives mpg123 time to fully spawn before the console exits. R.O. |
Thanks for pointing out the nohup command... I was already doing the &.
I'll give this script another shot. :D |
dammit, its not working.
here are the scripts, remember, security is not paramount: This runs on the server Code:
#!/bin/bash Code:
#!/bin/bash |
So, on the client side, when you run the script, what happens. It doesn't exit, or mpg123 doesn't start playing?
R.O. |
well, audio_script runs on radioserver (a file repository where people dump wavs) It runs a 3pm every day. It then sshs into the other two machines and runs the scripts. It works great.
Unfortunately, I end up with a ton of ssh processes after a while. |
All times are GMT -5. The time now is 02:57 PM. |