【发布时间】:2021-01-07 21:44:45
【问题描述】:
在任何其他 linux 发行版上,我都可以使用 shebang 创建一个文件并像这样运行 shell 脚本:
$ chmod +x test.sh
$ ./test.sh Johnny
hello Johnny
但在 Google Cloud Platform Container-Optimized OS 上,我收到 -bash: ./test.sh: Permission denied
如果我以 sh 为前缀,例如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
【问题讨论】:
标签: google-cloud-platform google-container-os