Rachel
Rachel

Reputation: 103397

Unable to run ssh inside shell script

I am able to run ssh rach@kamel but if i try to put this in bash script, i get command not found.

Here is the bash script in question

#!/bin/bash
ssh rach@kamel

i also tried using kamel ip address instead, still same issue.

Update Here is the Exact message

$ ./devBuild.sh
: No such file or directory../
: command not found

Update Content of cat -A devBuild.sh

$ cat -A devBuild.sh
#!/bin/bash^M$
cd ../^M$
ssh [email protected] ^M$

Update : Now am getting

$ ./devBuild.sh : hostname nor servname provided, or not known

Upvotes: 2

Views: 872

Answers (3)

pizza
pizza

Reputation: 7630

^M$ is symptom of DOS line-end, fix that and you should be good.

Upvotes: 4

glglgl
glglgl

Reputation: 91017

Do you, by any chance, have the line endings wrong? Sometimes it happens that there is a \r\n at the end of lines instead of a mere \n. This makes the shebang (#!) line dysfunctional.

Could you post the result of cat -A dev.sh, especially the first line?

Upvotes: 3

Gerald Spreer
Gerald Spreer

Reputation: 413

Is your script executable? If not use chmod +x dev.sh

Upvotes: 0

Related Questions