简体   繁体   English

当解释器处于非标准位置时,如何解决“错误的解释器”错误?

[英]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.

相关问题 如何使用非标准外键创建 hasMany 关系 - How do I create a hasMany relationship with non-standard foreign keys 如何在PHP中创建随机,非标准字符的字符串? - How do I create a string of random, non-standard characters in PHP? 如何设置主机的PHP解释器以指向容器的PHP解释器 - How do I setup my host machine's PHP interpreter to point to the container's PHP interpreter 如何在将PHP代码块传递给解释器之前重写它们? - How do I rewrite PHP code blocks before they are passed to the interpreter? 在将现有的php应用程序移植到CakePHP时,如何为模型使用非标准的表/列名称? - How do I use non-standard table / column names for the models while porting an existing php application to CakePHP? 如何获取非标准的php设置? - How to get non-standard php settings? 使用PHP,如何将引号添加到非标准INI文件中? - Using PHP, how can I add quotations to a non-standard INI file? 如何使用PHP检索和保存具有非标准基本名称的图像 - How can I retrieve and save images with non-standard basenames using PHP 如何在PHP中生成随机数以产生非标准分布 - How to generate random numbers to produce a non-standard distributionin PHP 如何通过非标准端口使用php fopen()? - How to use php fopen() with a non-standard port?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM