10 Replies - 1382 Views - Last Post: 05 February 2009 - 10:44 PM Rate Topic: -----

#1 redfla9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-February 09

how to excute program in php?

Posted 05 February 2009 - 09:24 PM

hi
i would like to know how to excute a program(.exe) with and without parameter, using php. where the program is on the server computer but in a diffrent directory.
At the moment i can use exec(ProgramName) but it only works with programs in the same folder as the php
so how may i change to execute in another directory and how can i add parameters such as "dsshost -port:50000 -tcpport:50001 "

This post has been edited by redfla9: 05 February 2009 - 09:26 PM

Is This A Good Question/Topic? 0
  • +

Replies To: how to excute program in php?

#2 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5393
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Re: how to excute program in php?

Posted 05 February 2009 - 09:45 PM

View Postredfla9, on 5 Feb, 2009 - 10:24 PM, said:

i would like to know how to excute a program(.exe) with and without parameter, using php.

The function that you are looking for is System.

View Postredfla9, on 5 Feb, 2009 - 10:24 PM, said:

where the program is on the server computer but in a diffrent directory.

Feed it the full path of the file, & as long as php or your hosting software has the privileges to execute that directory, you're all set.
Was This Post Helpful? 0
  • +
  • -

#3 redfla9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-February 09

Re: how to excute program in php?

Posted 05 February 2009 - 09:59 PM

system('[cd]&[C:\Documents and Settings\Brad\Microsoft Robotics Dev Studio 2008\bin\]&[binDssHost -port:50000 -tcpport:50001 -manifest:"C:\Documents and Settings\Brad\Microsoft Robotics Dev Studio 2008\samples\Config\MobileRobots.P3DX.Simulation.manifest.xml"]');
mega fail at life and code, where did I stuff up?

This post has been edited by redfla9: 05 February 2009 - 10:01 PM

Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5393
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Re: how to excute program in php?

Posted 05 February 2009 - 10:00 PM

I'm sorry... where did I stuff up?

You sure have a bad attitude towards someone trying to help you.

1.) You are using the system command incorrectly. Please actually try visiting the link I provided, & reading it.
2.) [cd]&[c:\...] is horribly wrong syntax. Learn how to use commands at the command prompt level, then try implementing it into PHP.
Was This Post Helpful? 0
  • +
  • -

#5 redfla9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-February 09

Re: how to excute program in php?

Posted 05 February 2009 - 10:07 PM

I as in me
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5393
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Re: how to excute program in php?

Posted 05 February 2009 - 10:08 PM

View Postredfla9, on 5 Feb, 2009 - 11:07 PM, said:

I as in me

;) it did say U, as in me.

Seriously though, the command syntax is horrible wrong, & the System command needs two parameters.
Was This Post Helpful? 0
  • +
  • -

#7 redfla9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-February 09

Re: how to excute program in php?

Posted 05 February 2009 - 10:19 PM

system('cd C:\Documents and Settings\Brad\Microsoft Robotics Dev Studio 2008\bin\DssHost -port:50000 -tcpport:50001 -manifest:"C:\Documents and Settings\Brad\Microsoft Robotics Dev Studio 2008\samples\Config\MobileRobots.P3DX.Simulation.manifest.xml"', $retval);
i'am i getting closer?
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5393
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Re: how to excute program in php?

Posted 05 February 2009 - 10:24 PM

Without knowing what this function is, or what it does, or if php has permission to run it, I would try the following. I'm not saying try it & tell it how it works out... I'm suggesting that you try it, look at the results, & see if you can figure out if it will work out.

Also... since I have no idea what it is that this function is or does, I'm going to assume that
<?php
$cmd="C:\Documents and Settings\Brad\Microsoft Robotics Dev Studio 2008\bin\binDssHost.exe";
$arg1="-port:50000";
$arg2="-tcpport:50001";
$arg3="-manifest"";

system("$cmd $arg1 $arg2 $arg3", $retval);
echo "<p><hr>The result was $retval</p>";
?>


Was This Post Helpful? 0
  • +
  • -

#9 redfla9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-February 09

Re: how to excute program in php?

Posted 05 February 2009 - 10:32 PM

ok thanks for the help
Was This Post Helpful? 0
  • +
  • -

#10 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5393
  • View blog
  • Posts: 27,387
  • Joined: 10-May 07

Re: how to excute program in php?

Posted 05 February 2009 - 10:33 PM

What is binDssHost? I'm curious.
Was This Post Helpful? 0
  • +
  • -

#11 redfla9  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 05-February 09

Re: how to excute program in php?

Posted 05 February 2009 - 10:44 PM

soz that was just one of many typos real file name Dsshost.exe used in hosting the Decentralized Software Services( therefore port address's), with arguments loads up a manifest that make a nice 3d simulation enviroment for robots
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1