【发布时间】:2016-05-23 00:47:58
【问题描述】:
我在我的一个 ubuntu 虚拟机中编写了一个 sh 脚本,它运行良好,但是当我尝试在我的其他虚拟机中运行它时,它不起作用。两个虚拟机应该相同。使用bash --version 两个虚拟机都回复:
GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
lsb_release -a,两人也回复:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
我的security_steps.sh 脚本如下所示:
#!/bin/sh
set -e
if ! [ -f svn_up_action.sh ]; then
echo "svn_up_action.sh is missing. Please make sure it is in the same directory as this script."
exit
fi
当我这样做时:sudo sh security_steps.sh,控制台错误:
: not foundeps.sh: 6: security_steps.sh:
security_steps.sh: 7: set: Illegal option -
我怎样才能弄清楚非工作外壳的虚拟机发生了什么?我觉得贝壳有点不同。感谢您的帮助!
【问题讨论】:
-
这不是 bash 脚本,因此不应将问题标记为 bash。
/bin/sh是 POSIX sh,而不是 bash。 -
另外,您可能的潜在问题是第一件事,stackoverflow.com/tags/bash/info 的标签 wiki 告诉您在询问之前检查。
-
...同样,
bash --version的输出与使用#!/bin/sh而不是#!/bin/bash的脚本完全无关。 -
@CharlesDuffy 非常感谢您提供的链接!是的,每行末尾都有
^M -
@CharlesDuffy 是的,
dos2unix解决了我的问题。谢谢。