Jump to content

send variables to cmd php file


The Little Guy

Recommended Posts

There is an array called $argv that you can use to access arguments passed via the command line. For example if you did the command

path/to/php/test.php chocolate 276 "killer tie, dude!"

 

and in that page you had a line

print_r($argv);

 

it would output something like

Array
(
    [0] => test.php
    [1] => chocolate
    [2] => 276
    [3] => killer tie, dude!
)

 

notice that the script name is the first parameter, always

 

there is also a variable $argc which is the count of the array $argv.

 

 

Link to comment
Share on other sites

Is there anyone to keep the code going that ran the exec?

 

I notice that if I have that, it waits till my other code is finished before it continues.

 

When working with linux, I could just do this:

> /dev/null 2>&1

 

It would then run the file, and not wait for the exec to complete it would continue execution of the current file and the other file would just finish when it is done...

 

Make sense?

Link to comment
Share on other sites

I'm not sure, but i read this on the PHP manual

Note: If a program is started with this function, in order for it to continue running in the background, the output of the program must be redirected to a file or another output stream. Failing to do so will cause PHP to hang until the execution of the program ends.

system()

Link to comment
Share on other sites

not sure if this will work but try this:

 

<?php
  $shell = new COM('WScript.Shell');
  $shell->Run("cmd /c php whatever/blabla.php flags");
?>

 

again not sure if it will work, just giving a suggestion, I know for a fact though that the script doesn't hang whatsoever with COM objects, so if it does do what its supposed to it should be a pretty good solution.

 

~~~

 

Tested and Works :) Have fun dude

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.