run executable file on server
Moderator: General Moderators
-
papa_smurf
- Forum Newbie
- Posts: 14
- Joined: Tue Jun 01, 2010 12:22 pm
run executable file on server
Hey all,
My dilemma is that I need to run a simple .exe file on my server. All it does is take an input txt file, runs some calculations and spits out data into an output txt file. Those files are named as:
SEA-R001-IN-1.txt
SEA-R001.exe
SEA-R001-OUT.txt
Does anyone know how I can write code to do this for me?
Thanks.
My dilemma is that I need to run a simple .exe file on my server. All it does is take an input txt file, runs some calculations and spits out data into an output txt file. Those files are named as:
SEA-R001-IN-1.txt
SEA-R001.exe
SEA-R001-OUT.txt
Does anyone know how I can write code to do this for me?
Thanks.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
Code: Select all
exec()mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
papa_smurf
- Forum Newbie
- Posts: 14
- Joined: Tue Jun 01, 2010 12:22 pm
Re: run executable file on server
Ok so using that exec() command would this work:
Thats exactly how I would type it into command prompt and run it. Just tell me if i'm wrong. I'm still new to a lot of this stuff.
Code: Select all
<?php
exec('/templates/paperchine/programs/SEA-R001/SEA-R001.exe, /templates/paperchine/programs/SEA-R001/SEA-R001-IN-1.txt, /templates/paperchine/programs/SEA-R001/SEA-R001-OUT.txt');
?>- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
It should work, if: the webserver has permission to run that exe and if it has permission to write the out file to /templates/paperchine/programs/.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
papa_smurf
- Forum Newbie
- Posts: 14
- Joined: Tue Jun 01, 2010 12:22 pm
Re: run executable file on server
Ok, so no go with that last try.
I have my files located at:
http://www.bffireworks.com/templates/pa ... 1-IN-1.txt
http://www.bffireworks.com/templates/pa ... A-R001.exe
http://www.bffireworks.com/templates/pa ... 01-OUT.txt
did I screw up in how I wrote my exec() php?
When I use this program I save all the files in my c drive and use command prompt and type:
C:\>SEA-R001.exe SEA-R001-IN-1.txt SEA-R001-OUT.txt
I have my files located at:
http://www.bffireworks.com/templates/pa ... 1-IN-1.txt
http://www.bffireworks.com/templates/pa ... A-R001.exe
http://www.bffireworks.com/templates/pa ... 01-OUT.txt
did I screw up in how I wrote my exec() php?
When I use this program I save all the files in my c drive and use command prompt and type:
C:\>SEA-R001.exe SEA-R001-IN-1.txt SEA-R001-OUT.txt
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
Your paths aren't correct. They most likely are similar to this, but you'll have to check. I assume the server is linux?
[text]/var/www/templates/paperchine/programs/SEA-R001/[/text]
Do this to see:
Or if your PHP script is in the directory above templates, then just leave off the preceding slash:
[text]templates/paperchine/programs/SEA-R001/[/text]
[text]/var/www/templates/paperchine/programs/SEA-R001/[/text]
Do this to see:
Code: Select all
exec("pwd");[text]templates/paperchine/programs/SEA-R001/[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
papa_smurf
- Forum Newbie
- Posts: 14
- Joined: Tue Jun 01, 2010 12:22 pm
Re: run executable file on server
So I ran:
from testing.php (located in same folder as the program I want to execute) and I got the following as a result:
I'm also using Joomla to set up my site, if that affects anything.
Code: Select all
<?php
echo exec("pwd");
?>Code: Select all
/var/www/vhosts/bffireworks.com/httpdocs - AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
So all of the paths would probably be like this:papa_smurf wrote:So I ran:from testing.php (located in same folder as the program I want to execute) and I got the following as a result:Code: Select all
<?php echo exec("pwd"); ?>
I'm also using Joomla to set up my site, if that affects anything.Code: Select all
/var/www/vhosts/bffireworks.com/httpdocs
[text]/var/www/vhosts/bffireworks.com/httpdocs/templates/paperchine/programs/SEA-R001/[/text]
Or you could just make it relative like I said in the previous post (this would be more portable):
[text]templates/paperchine/programs/SEA-R001/[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
papa_smurf
- Forum Newbie
- Posts: 14
- Joined: Tue Jun 01, 2010 12:22 pm
Re: run executable file on server
So if I wrote the php correctly it should look like:
Right? Like I said before, this is all new to me. Hope I'm not frustrating you too much! Thanks for all your help thus far.
Code: Select all
<?php
exec('/var/www/vhosts/bffireworks.com/httpdocs/templates/paperchine/programs/SEA-R001/SEA-R001.exe /var/www/vhosts/bffireworks.com/httpdocs/templates/paperchine/programs/SEA-R001/SEA-R001-IN-1.txt /var/www/vhosts/bffireworks.com/httpdocs/templates/paperchine/programs/SEA-R001/SEA-R001-OUT.txt');
?>- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
Does that work?
I would try:
And see if you get errors.
FYI passthru() is exec() but outputs all of the results.
I would try:
Code: Select all
passthru('./templates/paperchine/programs/SEA-R001/SEA-R001.exe ./templates/paperchine/programs/SEA-R001/SEA-R001-IN-1.txt ./templates/paperchine/programs/SEA-R001/SEA-R001-OUT.txt');FYI passthru() is exec() but outputs all of the results.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
papa_smurf
- Forum Newbie
- Posts: 14
- Joined: Tue Jun 01, 2010 12:22 pm
Re: run executable file on server
As far as I can see neither bit of code did anything at all.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
Code: Select all
error_reporting(E_ALL);
ini_set('display_errors', '1');mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
-
papa_smurf
- Forum Newbie
- Posts: 14
- Joined: Tue Jun 01, 2010 12:22 pm
Re: run executable file on server
Not sure what that was supposed to do, but it didn't do anything when I added it to the other code
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
That should go at the top of the script and should turn on error reporting. If you don't get errors then I can't help you.papa_smurf wrote:Not sure what that was supposed to do, but it didn't do anything when I added it to the other code
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: run executable file on server
Also, if that's a windows executable then its probably not going to run on linux. Maybe if you installed WINE, but that's usually not an option if this is shared hosting.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.