Pregunta

Well, I'm new to linux so this may be a very newbie kinda of thing, here it goes:

I have a script in which I'm trying to send some different jobs to remote computers (in fact Amazon's EC2 instances), these jobs are in fact the same function which I run with different parameters.

eventually in the script code I have this line:

nohup ssh -fqi key.pem ubuntu@${Instance_Id[idx]} $tmp

if I do:

echo nohup ssh -fqi key.pem ubuntu@${Instance_Id[idx]} $tmp

I get:

nohup ssh -fqi key.pem ubuntu@ec2-72-44-41-228.compute-1.amazonaws.com '(nohup ./Script.sh 11 1&)'

Now the weird thing. If I run the code with no echo in the script it doesnt work! it says in the nohup.out (in my laptop, no nohup.out is created in the remote instance) bash: (nohup ./Script.sh 10 1&): No such file or directory

The file does exist locally and remotely and is chmod +x. If I simply run the very same script with an echo in front of the problematic line and copy its output and paste in the terminal, it works!.

Any clues welcome, thanks!

¿Fue útil?

Solución

The problem is the single quotes around the nohup command in your $tmp variable. These don't get used on the shell locally, so SSH passes them verbatim. This means remotely the ssh server tries to interpret (nohup ./Script.sh 10 1&) as a command (looks for a file named that) which there clearly isn't. Make sure you remove the single quotes in $tmp.

Otros consejos

Try removing the single quotes from $tmp. It looks like bash is treating (nohup ./Script.sh 10 1&) as the command with no parameters, but technically nohup is the command with the parameters ./Script.sh 10 1.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top