在任何其他 linux 发行版上,我可以创建一个带有 shebang 的文件并运行 shell 脚本,如下所示:
$ chmod +x test.sh
$ ./test.sh Johnny
hello Johnny
但是在 Google Cloud Platform Container-Optimized OS 上,我得到了-bash: ./test.sh: Permission denied
sh
如果我以eg作为前缀,sh test.sh Johnny
它将起作用。我怎样才能让它正常工作?
$ cat test.sh
#!/usr/bin/env sh
echo "Hello $@"
matt@rancher-4mmm /tmp/matt $ chmod +x test.sh
matt@rancher-4mmm /tmp/matt $ sh ./test.sh matt
Hello matt
matt@rancher-4mmm /tmp/matt $ ./test.sh matt
-bash: ./test.sh: Permission denied
matt@rancher-4mmm /tmp/matt $ ls -la
total 4
drwxr-xr-x 2 matt matt 60 Feb 28 20:00 .
drwxrwxrwt 14 root root 280 Feb 28 19:59 ..
-rwxr-xr-x 1 matt matt 35 Feb 28 20:00 test.sh