Using Exec: pass an argument to be used as php var

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

Using Exec: pass an argument to be used as php var

Post by dickey »

Consider the following code:

Code: Select all

 
<?PHP
  $arg ='sometext';
  $WshShell = new COM("WScript.Shell");
  $oExec = $WshShell->Run("externalprogram.bat $arg", 7, false);
 
  // contents of externalprogram.bat
  //@C:\php\php.exe -q process.php?sometext=%1
?>
 
[If it is possible] I am trying to declare a var in PHP $arg (fine), pass it as an argument to an external program using exec (fine), and then pass that argument (represented as %1) as a var to an external PHP script (bombs).

By experimentation I can't get this to work. I would appreciate some advice.

Kind regards, Andrew
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Using Exec: pass an argument to be used as php var

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

Re: Using Exec: pass an argument to be used as php var

Post by dickey »

Thanks VladSun, your recommended view topic was spot on again. A great time saver - funny that syntax was just about the only variation I hadn't tried.

Kind regards, Andrew
Post Reply