efficacious Posted August 26, 2008 Share Posted August 26, 2008 hello everyone, i have some questions about the exec() function.. first off.. will this function execute from START>RUN or from CMD? I have an application I wish to run via the START>RUN and I need to trigger it from php.. hope I am explaining this decent enough for you guys to understand what I'm wanting to do. thanks, eff Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/ Share on other sites More sharing options...
aschk Posted August 26, 2008 Share Posted August 26, 2008 Basically it allows you to execute commands as if you were on the cmd line of your respective system, so if you run the script with exec() on a windows machine it's the same as using a cmd prompt, if you run it on linux it's the same as using a bash shell prompt. Linux however is strict about permissions, so you're only going to be able to run commands that Apache has privileges to run, however I cannot speak for what windows will allow you to do Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-625923 Share on other sites More sharing options...
efficacious Posted August 26, 2008 Author Share Posted August 26, 2008 well i've tested wether or not what I want to do will run.. I just wanted to know if it would run on cmd or RUN, through the php exec() function, but I kinda already knew it in my head it was CMD.. thanks for confirming.. I guess if I added winrar to the windows %PATH% then it should work from CMD thanks for your response aschk, eff Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-625925 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 Unless WinRAR has a CMD interface (not sure...), you won't be able to use it. PHP can't launch GUIs. Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-625934 Share on other sites More sharing options...
efficacious Posted August 26, 2008 Author Share Posted August 26, 2008 no no it has a CMD ln interface I kno code can't lauch GUI's hence the name right... Graphical User interface. Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-626008 Share on other sites More sharing options...
efficacious Posted August 26, 2008 Author Share Posted August 26, 2008 I have been toying around with this for a few minutes tho.. I can get it to work in the CMD if I use the CHDIR command and change the directory to the winRAR directory.. then it allows me to use the WinRAR command... I also trying adding in the path to the windows enviroment variables path.. but to no avail. I'm wondering tho.. if I was to say something like: <?php exec('CHDIR c:\program files\winrar\'); exec('WinRAR <my winrar command code>'); would that work? or would the second time exec is run it would be back at the default directory? thanks, eff Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-626015 Share on other sites More sharing options...
BlueSkyIS Posted August 26, 2008 Share Posted August 26, 2008 fwiw: php can start some programs that have a GUI, if that program provides an API to do so. carry on... Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-626017 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 You could either give a full path to the program (recommended) or just use the chdir() PHP function. I would really just give a full path. Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-626023 Share on other sites More sharing options...
Fadion Posted August 26, 2008 Share Posted August 26, 2008 Sorry if im off, but WinRar provided a command line tool called "Rar.exe". Place it in the "c:\windows" directory and execute it: <?php system('Rar.exe -parameters'); //which will print the output ?> Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-626036 Share on other sites More sharing options...
DarkWater Posted August 26, 2008 Share Posted August 26, 2008 Btw, what exactly are you trying to do with WinRAR? Create an archive or unpack one? Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-626039 Share on other sites More sharing options...
efficacious Posted August 26, 2008 Author Share Posted August 26, 2008 well you not quite off, they do include rar.exe for commandline but it is extremely limited. all is well I've been reading their documentation and decided to recheck my entry into the windows %PATH% using other program entries as a ref I found I shouldn't have added the program name WinRAR.exe... I took that off and just placed c:\Program Files\WinRAR\ in the path.. now its letting me run from the CMD.. so I think this is resolved.. THANKS ALOT GUYS!!! lots of good suggestions, eff @dark...Create Quote Link to comment https://forums.phpfreaks.com/topic/121399-solved-execrun/#findComment-626040 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.