Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sh script not finding variables

Tags:

linux

sh

I am following a tutorial on how to run a reverse ssh tunnel which is found at http://wiki.fabelier.org/index.php?title=Permanent_Reverse_SSH_Tunneling Issue I am having is when I run the tunneling.sh script:

#!/bin/sh
a=`ps -ef | grep 19999 | grep -v grep`
if [ ! "$a" ]; then
    ssh -fN -R 19999:localhost:22 <middle-usename>@<middle-hostname>
fi

I receive this error:

tunnel2.sh: 2: tunnel2.sh: a: not found

EDIT:

I changed shebang to #!/bin/bash

now I get this error:

tunnel2.sh: 2: tunnel2.sh: pi: not found
like image 855
Richard Avatar asked Sep 04 '26 00:09

Richard


1 Answers

Don't specify #!/bin/sh in your "shebang" line if you're going to use bash features. If you want bash, ask for bash.

like image 78
Paul Tomblin Avatar answered Sep 05 '26 12:09

Paul Tomblin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!