我正在学习如何运行反向 ssh 隧道的教程,该教程位于 http://wiki.fabelier.org/index.php?title=Permanent_Reverse_SSH_Tunneling。我遇到的问题是当我运行 tunneling.sh 脚本时:
#!/bin/sh
a=`ps -ef | grep 19999 | grep -v grep`
if [ ! "$a" ]; then
ssh -fN -R 19999:localhost:22 <middle-usename>@<middle-hostname>
fi
我收到此错误:
tunnel2.sh: 2: tunnel2.sh: a: not found
编辑:
我将 shebang 更改为 #!/bin/bash
现在我得到这个错误:
tunnel2.sh: 2: tunnel2.sh: pi: not found
最佳答案
如果您要使用 bash 功能,请不要在您的“shebang”行中指定 #!/bin/sh
。如果你想要 bash,请要求 bash。
关于linux - sh脚本找不到变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13709315/