[solved] shell_exec isn't working...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

[solved] shell_exec isn't working...

Post by Ambush Commander »

This line of code isn't working:

(used

Code: Select all

since entities don't seem to be working within

Code: 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::
Post Reply