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.

Second problem is that when I try to execute the following PHP script via SSH…

Read More
./searchreplacedb2cli.php -h hostname -u username -d databasename -p 'password'

…I get a /usr/bin/php: bad interpreter: No such file or directory error. This is because on shared hosting, there is no /usr/bin/php. Instead, the php cli I want is located here:

/usr/local/php5_3/bin/php

So, I manually changed the shebang declaration in the script to…

#!/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. I wget it from a git repository each time I use it. Furthermore it is deleted and installed regularly from a bash script, so modifying it in a text editor each time is not an option.

Is there a way to pass an alternate interpreter to a bash command? 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.

My next idea was to, via bash, edit line 1 of the php script using a sed replace command. I thought I would inquire here first for alternatives. Thanks.

Related posts

Leave a Reply

1 comment