ikkyino Posted May 29, 2008 Share Posted May 29, 2008 I'm unable to get exec() to work anymore, i've recently installed wamp and ever since it hasn't worked... I get no errors or anything... I'm kind of nubbish so I don't understand the ins and outs of the configs and stuff, i just need to know what needs to be activated or not and i hear all the crap about permissions and i have no idea what that is? Any help would be appreciated. Thanks! Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 29, 2008 Share Posted May 29, 2008 From what Google found, permissions shouldn't matter: http://www.onlamp.com/pub/a/php/2003/02/06...oundations.html If you are using PHP in a Windows environment (or other environment without a permission system), this column may not apply to you.What's your code? Maybe someone can test it with WAMP to see if they get the same result. (I can't, though... Long story.) Link to comment Share on other sites More sharing options...
Wander Posted May 29, 2008 Share Posted May 29, 2008 sometimes functions like exec are disabled in php.ini, go to php.ini and search for:disable_functionsthen see if it got exec behind it Link to comment Share on other sites More sharing options...
ikkyino Posted May 29, 2008 Author Share Posted May 29, 2008 $app = "'e:\bat\blizz.bat' e:\bat";exec ($app); just trying to execute a batch file but nothing happens... does it have to be in the directory of the site? It didn't have to before so i dunno... Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2008 Share Posted May 29, 2008 Are you sure that's not getting executed? Link to comment Share on other sites More sharing options...
ikkyino Posted May 29, 2008 Author Share Posted May 29, 2008 no dice... just acts as it normally does minus the actual execution of the batch file... could it be a directory issue? I'll try a few things and let ya'll know.. or if ya have an idea. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2008 Share Posted May 29, 2008 Try to use passthru instead of exec and see if you get any output. If the batch file doesn't print anything, call a batch file with a bunch of echo statements in it. Link to comment Share on other sites More sharing options...
ikkyino Posted May 29, 2008 Author Share Posted May 29, 2008 i don't really know how to use passthru but i reinstalled wamp...It executes the file now only in the background.. (it didn't before.. i checked....) so i'm getting... confused i guess you could say.... It takes up too many system resources for it to run in the BG and no /b is in anything.. idk what's going on.. i got this to work so i guess i'm grateful but it's not what i wanted >< Link to comment Share on other sites More sharing options...
justsomeguy Posted May 29, 2008 Share Posted May 29, 2008 passthru works exactly like exec except it prints the output from the program that you run. Link to comment Share on other sites More sharing options...
ikkyino Posted May 29, 2008 Author Share Posted May 29, 2008 Hmm... Okay it just gives me a path when i use passthru.... E:\wamp\www\srvrst>start e:\bat\blizz.lnkwhich is exactly what i have in my batch file, just to execute a link cuz exec blizz.lnk doesn't work But i still get teh same problem... It runs in the background when i need it to run in a regular window... It's not in the code or anything cuz it used to work just fine before i installed wamp, but everything was so old when it worked... lol.. i don't understand why it's running in the background, makes no sense, it must be something in the setup of wamp...Also it runs how i'd like when i run the .bat from my machine. Link to comment Share on other sites More sharing options...
ikkyino Posted May 29, 2008 Author Share Posted May 29, 2008 After doing some searching I think i found what the problem was... It was in services.. it would make it so it ran as a system process.. But here's the solution if anyone else runs into this problem...from http://us2.php.net/exec Win32 / PHP 4.3.6...If you plan to start programs on the server that show message boxes (things that require OK from the server-side), or remain (like notepad.exe), and the exec-command seems to go into an deadly loop, then MAYBE your program has started, but you can't see it. Because the web server runs as an system process, and it isn't allowed to interact with the desktop.To solve a part of the problem (to see the programs you execute), in the control panel in Windows, goto Administration->Services, right-click the server-service, goto Properties and on the second tab (login?) and check the box about allowing the service to interact with the desktop. Click OK. Restart the webserver, and MAKE SURE it is restarted for real (i.e. look in the task manager so the service goes _down_), otherwise the desktop-option won't take.Next phase would be to stop PHP from waiting for the processes to complete (this is what makes PHP "loop"). I solved this by creating a small Delphi-application that took the path to the file I wanted to execute and executed it by the WinExec API, which just starts the childprogram but doesn't wait for it to complete = the program completes and the PHP.exe completes the script. Problem solved!Delphi-snippet:WinExec(PChar(<CMD>),SW_SHOW); // replace <CMD> with the program path. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.