Tag: 回声

如何在Docker中创build一个bash脚本文件?

我写了一个脚本,任务是创build一个文本文件并写入两行。 这已经完成,但不止一次,我不明白为什么,因为脚本文件不包含任何循环,一旦文件执行。 #!/bin/bash <other, non-relevant variables and commands> PHP_ROOT_DIR=/etc/php-5.6.22 PHP_CGI_WRAPPER=php-5622 mkdir -p $(dirname $0)/cgi-bin touch $(dirname $0)/cgi-bin/$PHP_CGI_WRAPPER echo -e "#!/bin/bash" >> $(dirname $0)/cgi-bin/$PHP_CGI_WRAPPER echo -e "exec ${PHP_ROOT_DIR}/bin/php-cgi" >> $(dirname $0)/cgi-bin/$PHP_CGI_WRAPPER <other, non-relevant variables and commands> exit 0 输出文件内容: #!/bin/bash exec /etc/php-5.6.22/bin/php-cgi #!/bin/bash exec /etc/php-5.6.22/bin/php-cgi #!/bin/bash exec /etc/php-5.6.22/bin/php-cgi 更新: 运行Docker容器时会出现此结果。 如果我将脚本简化为只包含以上部分(删除不相关的代码部分),然后在主机操作系统和Docker中正确工作。 但问题仍然没有解决。 完整版本的脚本文件是这样的: #!/bin/bash source $(dirname […]