I have a webpage on a linux NAS, with webserver and php running.
I want to start a script from de server, to write data to a database.
When i am on the new69.php (the website in question)
I have the
for example :
$uptime = exec('uptime');echo $uptime;
(and this works)
So i have a connection.
Then i do with a if statement:
if (isset($_POST['verzenden'])) {
$output1 = exec('whoami');
exec('/share/MD0_DATA/Qweb/sqlite/AllesNaardDB.sh');
} else {
echo "Nog lekker niets gedaan.";
Whoami in the is statememt gives the username “httpdusr”,
So the if statement gets reached and works.
Now the exec statement when i do:
It has to execute the AllesNaardDB.sh
which contains:
cd /share/MD0_DATA/Qweb/sqlite
echo "Wasmachine"
python2.6 wasm_util_sql.py [param]
echo "alles gegeven"
exit 0
Nothing is shown or done.
But when i do:
$output = exec('/share/MD0_DATA/Qweb/AllesNaardDB.sh');
echo "<pre> $output </pre>";
I get the als line of the script in the variable $output,
“alles gegeven”.
At first i tought that it could be something to do with the rights.
So i (switched user with) su to “httpdusr” and script in putty gets executed fine.
I also made another script ff.sh with “ls -l” to execute and everything works.
Also i treid
passthru(),
system(),
shell_exec.
The only improvements are that with system() and passthru(), the “echo “Wasmachine””
appeared on te website.
I don’t get why the python jobs don’t get started ?
I worked a little further, but could it be that there are some sqlite3 command which are user dependent ?
Like that i could execute some write action to the database as admin, but not as the httpdusr ?
It is a prblem with a path in the python script, which is writing to the database.
It uses a different path when it is started from the webpage (MD0_DATA/Qweb/) then wen it is started from the shell script (MD0_DATA/Qweb/sqlite)
*i dit not solvend the problem yet, but understand it.
Everybody thanks for the effort.