LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Cannot run shell script on the remote server (http://www.linuxquestions.org/questions/linux-general-1/cannot-run-shell-script-on-the-remote-server-545985/)

haresh_dba 04-14-2007 06:40 AM

Cannot run shell script on the remote server
 
Hi

I`m unable to execute my shell script on the remote db server for monitoring. However i`m able to connect the remote server but the scripts are not executing remotely.

I would like to run the scripts on the remote box

Please help

MensaWater 04-14-2007 08:40 AM

You can't execute a script from a local box on a remote box. You can however put in commands to execute on a remote box from the local box OR you can copy the local script to the remote box then use the local box to tell it to run there.

Say you had a simple script and named it "showme.sh"
Code:

#!/bin/bash
ls -l
df -h

This script should run fine on the local box just by typing "./showme.sh". However if you tried to run it remotely by typing:

ssh user@remotehost ./showme.sh

It wouldn't work because showme.sh doesn't exist on the remote. You could simply copy this to the remote host and then run it.

Alternatively you could modify the script:
Code:

ssh user@remotehost "/bin/ls -l"
ssh user@remotehost "/bin/df -h"

Here you're telling it to execute each of the commands of the script remotely. The downside of this is that if you don't have an ssh trust setup it will prompt you for the password each time it executes and ssh in the script.

XavierP 04-14-2007 09:26 AM

Moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.


All times are GMT -5. The time now is 05:42 AM.