2015-04-24 40 views
1

无法解释为什么会发生这种情况。这里的脚本:基本bash脚本返回“无效语法”

#!/bin/bash 
echo "Hello World" 

这里的终端输出:

$ python ./test.sh 
    File "./tellapart_mac_setup.sh", line 2 
     echo "Hello World" 
     ^
SyntaxError: invalid syntax 

$ echo "hello world" 
hello world 

$ which bash 
/bin/bash 

$ /bin/bash --version 
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14) 
Copyright (C) 2007 Free Software Foundation, Inc. 

回答

5

你看上去与蟒蛇解析它,因为它不是一个Python脚本 - 它当然会扔在python的编译器错误。

这是一个bash脚本,所以只需使用bash来处理它:

./test.sh