1

I need to execute a program using php, the file in question is ClustalW (clustalw2). My apache user is http using fish shell, so I moved clustalw2 to /srv/http/Clustal and added the dir to fish path.
If I log in into http using terminal and run clustalw2 -INFILE=input_file -OUTFILE=output_file everything works as expected.
But every time I run shell_exec('clustalw2 -INFILE=input_file -OUTFILE=output_file'); nothing happens and I get this error log: sh: line 1: clustalw2: command not found


If I run:

<?php
echo "USER: ".shell_exec('whoami')."<br>";
echo "SHELL: ".shell_exec('echo "$SHELL"')."<br>";
echo "WHICH clustalw2: ".shell_exec('which clustalw2');

Output:
USER: http
SHELL: /usr/bin/fish
WHICH clustalw2:


If I run which clustalw2 in terminal using http user:

/srv/http/Clustalw/clustalw2

1 Answer 1

2

Your program can't find clustalw2 because clustalw2 isn't in the $PATH.

In your case, the easiest solution is to replace clustalw2 with the full path, /srv/http/Clustalw/clustalw2 as the first parameter to shell_exec.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.