Run Bash Scripts From Php

I’m developing a web application that has to run some bash scripts. I tried to use shell_exec,exec and system function but i always obtain an error page.

the line of code that generate the error is this

system("scripts/1-All-Interactors.bash $Protein");

i’ve already tried to set permission of www-data but nothing is changed.

any idea?

thanks in advance

What’s the error that you’re getting? It’s likely that PHP is running in a protected mode that is preventing you from executing system code.

I get the same page you get when a server is down. PHP has safe mode off, is protected mode the same thing?

Try with exec, but start with a basic system call to ensure that exec can be successfully run. Try the following from PHP’s docs:


Also make sure you turn on all error reporting for the purposes of debugging this.