[英]Bash check environment var is set fails doesn't work
just playing around on my server to get script the setup of the next server. 只是在我的服务器上玩耍以获取下一个服务器设置的脚本。 Everything works - now I want to run it on the new server i got an error like this:
一切正常-现在我想在新服务器上运行它,我得到了这样的错误:
sudo sh setup.sh Hostname is dinozzo setup.sh: 10: setup.sh: [[: not found
sudo sh setup.sh主机名是dinozzo setup.sh:10:setup.sh:[[:找不到
The Script to start is not that much. 启动的脚本并不多。 Line 10 is
第10行是
if [[ "$INT_DEV_HOSTNAME" ]];
如果[[“ $ INT_DEV_HOSTNAME”]]; then
然后
But I don't get it why it is not working on Ubuntu 14.04.5 LTS. 但是我不明白为什么它不能在Ubuntu 14.04.5 LTS上运行。
You explicetly tell the shell to use sh : 您明确告诉shell使用sh:
sudo sh setup.sh Hostname is dinozzo setup.sh: 10: setup.sh: [[: not found
In this mode, even if it's bash that you are using by default, it will produce the error because it will be in POSIX mode. 在此模式下,即使默认情况下使用的是bash ,也会因为在POSIX模式下而产生错误。
[[ ]]
form of test
need to be called from within a bash shell (other shells support it too, like ksh, zsh...) 需要在bash shell中调用
[[ ]]
test
形式(其他shell也支持它,例如ksh,zsh ...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.