[英]How do I solve “bad interpreter” error when interpreter is in non-standard location?
So my first problem is that I'm hosting on GoDaddy. 所以我的第一个问题是我在GoDaddy上主持。
Second problem is that when I try to execute the following PHP script via SSH... 第二个问题是当我尝试通过SSH执行以下PHP脚本时...
./searchreplacedb2cli.php -h hostname -u username -d databasename -p 'password'
...I get a /usr/bin/php: bad interpreter: No such file or directory
error. ...我得到一个/usr/bin/php: bad interpreter: No such file or directory
错误。 This is because on shared hosting, there is no /usr/bin/php
. 这是因为在共享主机上,没有/usr/bin/php
。 Instead, the php cli I want is located here: 相反,我想要的php cli位于:
/usr/local/php5_3/bin/php
So, I manually changed the shebang declaration in the script to... 所以,我手动将脚本中的shebang声明更改为...
#!/usr/local/php5_3/bin/php -q
...and sure enough, it works. ......果然,它有效。
However, I don't want to have to edit this script manually. 但是,我不想手动编辑此脚本。 I'm looking for a way to circumvent this issue programmatically. 我正在寻找一种以编程方式绕过这个问题的方法。 I use this script to deploy Wordpress sites on the fly. 我使用此脚本动态部署Wordpress站点。 I wget
it from a git repository each time I use it. 我wget
从一个Git仓库每次使用它的时候了。 Furthermore it is deleted and installed regularly from a bash script, so modifying it in a text editor each time is not an option. 此外,它会从bash脚本中定期删除和安装,因此每次都无法在文本编辑器中对其进行修改。
Is there a way to pass an alternate interpreter to a bash command? 有没有办法将备用解释器传递给bash命令? Like, "if you don't find the default interpreter, use this one instead". 比如,“如果你找不到默认的解释器,请改用它”。
I tried this but it doesn't work: 我试过这个,但它不起作用:
./searchreplacedb2cli.php -h hostname -u username -d databasename -p 'password' | /usr/local/php5_3/bin/php
And because it's shared hosting I lack the permissions to symlink /usr/bin/php to the right place. 因为它是共享主机我缺乏symlink / usr / bin / php到正确位置的权限。
My next idea was to, via bash, edit line 1 of the php script using a sed
replace command. 我的下一个想法是,通过bash,使用sed
replace命令编辑php脚本的第1行。 I thought I would inquire here first for alternatives. 我想我会先在这里询问替代方案。 Thanks. 谢谢。
如果它只是这个主机,请将/ usr / local / php5_3 / bin /添加到$ PATH,并使用此shebang:
#!/usr/bin/env php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.