Jump to content

Running application in php


mmarif4u

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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.

 

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.