DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   executing a script remotely (http://www.daniweb.com/forums/thread158334.html)

curto21 Nov 19th, 2008 12:12 pm
executing a script remotely
 
I need help trying to execute a script remotely using ssh.

I'm writing a script that will run on a local machine. From that script I need to execute a script on a remote machine. The problem is that when I run the remote script using ssh, it's output is shown as if it were running locally. I need the script to run commands on the remote machine, not the local one. This is what I am doing:

ssh root@remoteServer /var/spool/asterisk/voicemail/default/script

That remote script needs to execute commands on files relative to its location on the remote machine. Maybe ssh isn't the best method to invoke this. Any help would be appreciated.

curto21 Nov 19th, 2008 12:14 pm
Re: executing a script remotely
 
by the way... this is being done in a bash script. Thanks!

eggi Nov 20th, 2008 12:16 am
Re: executing a script remotely
 
Hey there,

Interesting. your execution statement looks like it should work. You can hedge your bets by enclosing the remote command in quotes:

sh root@remoteServer "/var/spool/asterisk/voicemail/default/script"

also, to double verify, add the hostname command in there:

ssh root@remoteServer "hostname;/var/spool/asterisk/voicemail/default/script;hostname"

You should the remote host name, your output and the remote hostname again. If that works, just strip the hostname commands back out.

I'd be interested if this doesn't work. If possible, in the unfortunate event that you still experience your issue, could you send output from:

ssh -v -v -v root@remoteServer /var/spool/asterisk/voicemail/default/script

that'll give us insane debug output ;)

Best wishes,

Mike

chris5126 Nov 20th, 2008 11:05 am
Re: executing a script remotely
 
Are you sure that it isnt working it will run the script but pull any output back to the server you are working on. Put a large sleep in the script then log on to the server that your running the script on remotely to check whether it is exeucting or not!

DimaYasny Nov 20th, 2008 2:34 pm
Re: executing a script remotely
 
just redirect the output to the remote system log file


All times are GMT -4. The time now is 6:16 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC