Execute bash or PHP script remotely
Hello,
I have a bash/php script on a remote server that takes few line arguments. Both servers are centOS. So far in my research I have come across this where i could copy the bash script locally and execute it passing it to bash that executes it remotely: Code:
ssh root@REMOTE_HOST 'bash -s' < local_script.sh var1 var2 var3 Code:
wget http://remoteserver/bool.txt |
Hi,
I think it would be easier if you modified the script so that its exit value is is either 0 or 1 instead of writing to a file. Eg. Code:
#!/bin/sh Then copy the script to each of the servers, and run from the local host as follows Code:
ssh REMOTE_HOST remote_script.sh var1 var2 var3 HTH, Evo2. |
That did the trick for ssh; Thanks!, - however, I also needed it to work non-interactively; hence now i am using sshpass. But the return value as you suggested did not work - so now I am writing the bool to a file on the remote server and fetching it and then reading it...
|
maybe:
Code:
var=$(ssh REMOTE_HOST remote_script.sh var1 var2 var3) |
nice suggestion - but did not work.
var = $(sshpass -p password ssh user@ip-address /home/user/script.sh var1 var2) echo var Result (nothing) so i changed it to ticks var = `sshpass -p password ssh user@ip-address /home/user/script.sh var1 var2` Result: var1 var2 0 0 my script on the server returns 0; the other 0 might be from ssh; and var1/var2 from sshpass if nothing else - then i guess i will filter out the field |
Code:
echo $var BTW, no spaces around var assignments Code:
var=$(...) |
All times are GMT -5. The time now is 03:26 PM. |