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:

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

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

If I run which clustalw2 in terminal using http user:


1 Answer 1


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .