mmarif4u Posted July 3, 2008 Share Posted July 3, 2008 I tried to open a exe file in php,but got the error msg from the if statement: <?php if(exec('C:\Program Files\FileZilla Client\filezilla.exe')){ echo "run"; }else { echo "error"; } ?> mean that the command i am running is wrong. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/ Share on other sites More sharing options...
DyslexicDog Posted July 3, 2008 Share Posted July 3, 2008 Try this, post your new output. <?php if(exec('C:\Program Files\FileZilla Client\filezilla.exe', $output)){ echo "run"; }else{ echo "error"; } echo $output; ?> Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-580996 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 The spaces are messing it up. exec("'C:\Program Files\FileZilla Client\filezilla.exe'", $output) Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-580999 Share on other sites More sharing options...
DeanWhitehouse Posted July 3, 2008 Share Posted July 3, 2008 change the spaces to %20 Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581005 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 @Blade: Nope. That's not it. =X Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581006 Share on other sites More sharing options...
libertyct Posted July 3, 2008 Share Posted July 3, 2008 wow thats cool. i didn't know you could actually do that from a website. but how secure is this? this means anyone can run any program on my pc from their site? Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581011 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 You hardly want to do it unless you need some sort of functionality that you'd rather not code by hand in PHP, like ls | grep 'something'. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581014 Share on other sites More sharing options...
mbeals Posted July 3, 2008 Share Posted July 3, 2008 it might be a permissions thing. Does the user that php/apache is run under have permissions to execute that file? Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581021 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 Output is: errorArray Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581432 Share on other sites More sharing options...
DyslexicDog Posted July 4, 2008 Share Posted July 4, 2008 Try this then. <?php if(exec('C:\Program Files\FileZilla Client\filezilla.exe', $output)){ echo "run"; }else{ echo "error"; } print_r($output); ?> Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581465 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 the same output: errorArray ( ) really annoying this thing is now. working on it from last night. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581470 Share on other sites More sharing options...
DarkWater Posted July 4, 2008 Share Posted July 4, 2008 You tried my solution (the new quotation marks)? Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581471 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 Yup: <?php if(exec("'C:\Program Files\FileZilla Client\filezilla.exe'",$output)){ echo "run"; }else{ echo "error"; } print_r($output); ?> same result: errorArray() Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581473 Share on other sites More sharing options...
DarkWater Posted July 4, 2008 Share Posted July 4, 2008 Does entering: 'C:\Program Files\FileZilla Client\filezilla.exe' At the command line work? Also, try: $exec = "'C:\Program Files\FileZilla Client\filezilla.exe'"; if (exec($exec)) { ... } else { ... } Someone had a problem like that and I told them to try it and it worked. I don't know why, honestly. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581475 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 just tried from command,and it works fine.open the application. tried your new code: $exec = "'C:\Program Files\FileZilla Client\filezilla.exe'"; if (exec($exec)) { echo "ok"; } else { echo "error"; } Throwing the error. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581478 Share on other sites More sharing options...
trq Posted July 4, 2008 Share Posted July 4, 2008 Is this filezilla thing a gui based application? You won't hgave much (any) luck getting anything other than command line applications to execute. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581480 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 yup,its gui based application. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581482 Share on other sites More sharing options...
DarkWater Posted July 4, 2008 Share Posted July 4, 2008 Oh yeah, I completely forgot to look at the application name. You need to run a command line application to get it to really work. Why do you want to open Filezilla like that anyway? Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581483 Share on other sites More sharing options...
trq Posted July 4, 2008 Share Posted July 4, 2008 Then theres your problem. I'm not a windows user but I doupt apache has permssions to open any gui. Are you running this php script via apache? Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581484 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 @DarkWater: Actually i am running this for test.that just choose filezilla from c drive to run. @thorpe: Yup,PHP script is running via apache. Ok,in brief: I make a script for our client,for whom we buy a dedicated server running debian on it. That script will send sms to the client when there is overflow by some level in the real monitoring sensors.Now i cron that file to run after 2 minutes,if there are some values in the table which are greater than the mentioned level,so pick the specific data and send them to the client. Now the server is difinitly running LINUX,so i have to run it under linux. Now WHY i want to run a application through that script,i want to pass some arguments to new script(maybe in c or c++) to accept entries and then send that entries to client.the another script is used for sending sms and recieving arguments from the 1st script. So the another script will run,which will then pass the data to a GSM modem,and modem will send sms. IS there any better idea to do this. So mean job for this script is to run a application OR script in other lang and pass them some arguments. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581489 Share on other sites More sharing options...
DarkWater Posted July 4, 2008 Share Posted July 4, 2008 But it's not a GUI, right? Just a C++ program? Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581490 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 As i mention,i am running now a gui just for test. But i am sure later i think will use some other lang script to use.and i hope our another programmer has a script in C++ for GSM modem to send sms. There are also other ways to send sms,i am just learning and working on it.to find a better solution for it to send sms. Two ways i know are: 1) use any other site as Gateway 2) Or use the mobile operator as email reciepionest like: 1234566@vodafone.com Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581492 Share on other sites More sharing options...
trq Posted July 4, 2008 Share Posted July 4, 2008 Sounds like exec is the way to go, you just can't open gui applications with it and really, whats the point? Theres no one there (at the server) to see them. Linux programs execute without issue. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581493 Share on other sites More sharing options...
mmarif4u Posted July 4, 2008 Author Share Posted July 4, 2008 Haha,yup thorpe you are right there is no one to see the program. i have simple idea about a java file in linux based distro by using exec in php. like: <?php exec('java -Xmx32m -jar "/home/blahblahblah/mydomain/testjava/Test.jar"'); ?> And i hope C,C++ will be the same. How to pass arguments in it,any idea. Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581494 Share on other sites More sharing options...
allenskd Posted July 4, 2008 Share Posted July 4, 2008 Hmm.. you can't really launch applications (like mentioned above) although you can pretty much do all the commands command prompt allows Example <?php // output netstat $e = exec('netstat -n',$out); var_dump($out); // stops and starts mysql service $n = exec('NET STOP MYSQL',$out2); $n = exec('NET START MYSQL',$out2); var_dump($out2); // your system's information, takes a little while and uhh.. only for windows $system = exec('systeminfo',$info); var_dump($info); hope that helps! Quote Link to comment https://forums.phpfreaks.com/topic/113053-running-application-in-php/#findComment-581505 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.