![]() |
PHP exec(), passthru() and system() not working at all? Ubuntu LTS LAMP
Hey LQ,
For some reason I can't seem to get exec, passthru or system to run a specific command. It will run trivial commands such as "ls -l" but it will not run Code:
ssh -p 223 admin@server.com "mysqldump -u admin_db -pPassword databaseName | gzip -9 > /home/admin/sql-current/sql-current.gz" Any ideas on what's going on here? |
Is the PHP script run by web user or from command line?
|
What error are you getting?
|
Quote:
|
Quote:
|
Anyone! Please help!
|
What are you expecting it to do?
This will not return any message to the php so you will see nothing on that end. Are you saying that it does not produce the gzipped dump file? Just for fun, give it an invalid database name or user - something that will produce a mysql error - and see if that comes back to the php end (echo it out or capture to a variable). |
Quote:
I gave it an incorrect databasename and user and it didn't error. It's like it's failing before it even tries. I'll repeat, when doing something like PHP Code:
Code:
total 4 -rw-rw-r-- 1 wh33t wh33t 24 Sep 5 19:43 databasebackup.php |
Try something trivial via ssh, like...
Code:
$var = exec('ssh -p 223 admin@server.com "ls -l"'); exec will only return the last line of output, but if you connect you will see something, otherwise not. |
Quote:
|
Quote:
Anyway, glad you got it working! |
Quote:
|
Quote:
Code:
<?php Code:
Length: 58 One difference - I ran mine from a shell and this user has a password login. I was wondering if the fact that you hit if from a web server might not cause it to fail due to not having the user's fingerprint because it would be running as the webserver user. |
Quote:
|
It might be a solution to execute the ssh command with sudo and set a user for the execution in the sudoers file with visudo. You can set there that the command does not need a pssword prompt. Regarding security you run a high risk if you make database dumps availble thru a web interface.
|
All times are GMT -5. The time now is 04:03 AM. |