There is a php script, here's a piece of code from it.
$uploaddir = "/tmp/"; $updatedir = "/home/andy/test/"; $update_script_path = "/home/andy/updater.sh"; $uploadfile = $uploaddir.basename($_FILES['arch']['name']); $uploadfile = str_replace(' ', '', $uploadfile); if ($_FILES['arch']['tmp_name'] != "" && copy($_FILES['arch']['tmp_name'], $uploadfile)) { $update_script_path = escapeshellarg($update_script_path); $uploadfile = escapeshellarg($uploadfile); $updatedir = escapeshellarg($updatedir); $commandline = $update_script_path." ".$uploadfile." ".$updatedir; //echo "<pre>" . ($res = system($commandline)) . "</pre>"; echo "<pre>" . ($res = shell_exec($commandline)) . "</pre>"; //echo "<pre>" . ($res = exec($commandline)) . "</pre>"; //echo "<pre>" . ($res = system("/bin/sh -c /home/andy/updater.sh")) . "</pre>"; }
Do not be confused by the commented launch lines, I just tried various options. There is a simple bash script, the rights to execute it are installed.
#!/bin/sh tar -xvf $1 -C $2
Those. The php script takes the file from the user, forms a command line to run the bash script. The problem is that the bash script does not work, the script in bash both arguments are passed correctly, I checked it out of the bash script
echo $1 echo $2
The bash script should unpack the file that the user submitted via the form to the specified directory, but nothing happens. If I call my bash script "manually" from the console
root@test-device:/home/andy # ./updater.sh /tmp/files.tar.gz /home/andy/test/
That all works fine, as I can see from the code of the php script was played with different options, but did not get success (((