Reputation: 81
I have tried to run the following command from command line and it works perfect as expected
ssh someIP "java -jar /path/program.jar "someIP""
but when i wrote in the bash script as following:
ssh $f1 \"java -jar /path/program.jar \"$f1\"\" ;
where $f1 is the ip address. it does not work and gives me the error:
bash: java -jar /path/program.jar someIP: No such file or directory
I tried to echo the ssh command and it is correct and i just copied the echoed command and pasted on the command prompt and it has worked. So I am now confuse, what is wrong in the bash script that I am missing
Upvotes: 0
Views: 482
Reputation: 31
You can try not to escape.
#!/bin/bash
ssh $1 "java -jar program.jar "$1""
Upvotes: 3
Reputation: 140
You could try EOF.
ssh $1 << EOF
#commands here
EOF
After the commands are done the connection is severed.
Upvotes: 1