Linux.com

Home Linux Community Forums Software Command Line ssh - execute the script remotely / File not found

ssh - execute the script remotely / File not found

Link to this post 30 May 10

ssh - execute the script remotely / File not found: ''

I am uisng amazon ec2-api-tool & ec2-ami-tool

i was unable to execute through ssh.
Getting error as

File not found: ''

The same script i can able to run directly in client machine successfully.

Through ssh i was uanble to run the script remotely
Source : myScript.sh
ec2-create-volume --size $1 --availability-zone $2

$ssh -i key.pem root@myhost ./myScript.sh 10 us-east-1a
File not found: ''

Note:
i have read write permission to my remote machine script myScript.sh

What i might have done mistake...?

Link to this post 31 May 10

You must point to the absolute position of the script on the remote machine. Currently your ssh call is looking in the root directory for your script.

Link to this post 31 May 10

As you said i treid with following command,

$ssh -i key.pem root@<host> -C /root/myScript.sh
Output: File not found: ''

In remote machine, $ls -rtl myScript.sh
$-rwxr--r-- 1 root root 59 May 30 12:31 myScript.sh

Source: myScript.sh
ec2-create-volume --size 10 --availability-zone us-east-1a

Note: I can able to manually execute the command "ec2-create-volume --size 10 --availability-zone us-east-1a" successfully
If i want to execute the same with ssh via script, how i should procede. Please help me on this.

Link to this post 31 May 10

ssh -i key.pem root@<host> -C "sh /root/myScript.sh <args>"

Link to this post 31 May 10

I think mfilpot is right, you need to explain to your system how to run your script. An alternative to specifying the interpreter when you invoke the script, is to define the interpreter in the beginning of the script itself, like this:

#!/bin/sh
ec2-create-volume --size 10 --availability-zone us-east-1a
If you do this, I think your command should work fine:
ssh -i key.pem root@<host> -C /root/myScript.sh

Link to this post 31 May 10

jabirali wrote:

I think mfilpot is right, you need to explain to your system [i]how[/i] to run your script. An alternative to specifying the interpreter when you invoke the script, is to define the interpreter in the beginning of the script itself, like this:
[code]#!/bin/sh
ec2-create-volume --size 10 --availability-zone us-east-1a[/code]If you do this, I think your command should work fine:[code]ssh -i key.pem root@<host> -C /root/myScript.sh[/code]

I also want to note that if you are planning to add input arguments you may want to enclose the script path and arguments in quotes, although it can work without the quotes depending on the arguments.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board