[solved] shell_exec isn't working...
Posted: Mon Aug 08, 2005 2:50 pm
This line of code isn't working:
(used
(used
Code: Select all
since entities don't seem to be working withinCode: Select all
tags)
[code]$output = shell_exec("\"\\Documents and Settings\\Edward\\My Documents\\Programs\\7Zip\\7z312\\7za.exe\" a archive -r -i!\"New Text Document.txt\" ");[/code]
The result is: $output = ''
Funny thing is, these do work:
[php]$output = shell_exec("\"\\Documents and Settings\\Edward\\My Documents\\Programs\\7Zip\\7z312\\7za.exe\"");[/php]
[b]On the command line[/b] - I printed the command from the program and then directly spliced it in my command line and lo and behold it works.
[code]"\Documents and Settings\Edward\My Documents\Programs\7Zip\7z312\7za.exe" a archive -r -i!"New Text Document.txt"
[/code]
What could I possibly be doing wrong? This is really bugging me.
PHP 4.3.11, running Windows XP Home Edition.
[b]Edit[/b] Removing the -i flag fixes the problem, as does removing the quotes after the -i flag. But it's not what I want (without the quotes, it doesn't work out and I need the -i flag). Interestingly, I'm fairly sure that when using shell_exec on a different version of the program, it probably works.
[b]Edit 2[/b] Modifying the batch file pointing to the 7-Zip executable doesn't seem to break anything. This poses a bit of a conundrum.
[b]Solved[/b] Well, I waited around a while for an answer, and then I went off to find it myself. And do you know what the problem was? [b]I wasn't returning the value of STDERR[/b]! PHP Manual comments can do wonders. ::Goes AAAAARRRRRGGGGHHH:: ::brainfreeze::