I have a .sh
file and it has variables that I need to get from PHP, here's an example:
//variavel 1 que preciso receber externamente
NAME=""
//variavel 2 que preciso receber externamente
DIR=""
tar -zcf $HOME.tar.gz $DIR
Calling the file by PHP would look like this:
shell_exec('sh arquivo.sh');
I just need to know how to send the data from the 2 variables.
Another way would be to send the entire script directly through php via shell_exec()
, how would you send such a script ?
(This does not work):
shell_exec('VAR=tar -zcf teste.tar.gz teste/testeDir
if [ "$SUCCESS" == "0" ]; then
echo "Sucesso!"
else
echo "Sucesso!"
fi');