Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Windows Scheduler Task 1

Status
Not open for further replies.

jay123454

Programmer
Jun 15, 2001
46
US
I'm not too familiar with setting up php Windows Scheduler tasks. So hopefully someone here can help me. Trying to setup this task in Server2003/IIS6

This is what I have for the task...but I'm getting "No Input File Specified" everytime I run this. Any ideas? Is my syntax correct?

C:\PHP\php.exe C:\mydir\autorun\statistics.phpAutorun_Pin=mypassword
 
You're not trying to do a GET-method URL input to your script, are you? That only works through a web browser.

Instead, if you want to pass parameters to a script run from the command-prompt (which this is), you must do something like:

C:\PHP\php.exe C:\mydir\autorun\statistics.php /Autorun_Pin=mypassword

And have your script interpret $_SERVER['argc'] and $_SERVER['argv'] to figure out what parameters it's being passed at runtime.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Yes, was trying to pass a variable to the script. Now if I use REQUUEST will it work for this call and browser call?

$_REQUEST['Autorun_Pin'];


Or will I have to insert some other code to check for this?

Sorry, not familiar with
$_SERVER['argc'] and $_SERVER['argv']

Thanks!

 
I strongly recommend that you never, ever, under any circumstances use $_REQUEST. You might as well turn on register_globals, because in terms of variable poisoning, using $_REQUEST is as insecure.

$_POST, $_GET, $_COOKIE, etc, all require that they be populated by PHP. PHP, in most cases, must be passed this information by the web server. Which you don't have available.


$_SERVER['argc'] records how many parameters were passed on the command-line when the script was invoked. $_SERVER['argv'] is an array of those arguments. If you invoke PHP from the command-line as:

[C:\new_emails]php -q test_command-line.php /foo=bar

Then $_SERVER['argv'] will contain:

Array
(
[0] => test_command-line.php
[1] => /foo=bar
)




Want the best answers? Ask the best questions!

TANSTAAFL!!
 
So I'll have to parse argv for the variables I'm looking for?

$server_vars=$_SERVER['argv'];

So
//$server_vars[1]="/foo=bar&foo2=bar2";
if(strlen($server_vars[1])>0)
{
$vars=sub_str($server_vars[1], 1);
$vars=explode("&", $vars);
foreach($vars as $key => $val)
{
$$key=$val;
}
}
And then I'd have available in my script.
$foo="bar";
$foo2="bar2";


Correct?

 
Also,

What if I wanted to pass 2 variables?

C:\PHP\php.exe C:\mydir\autorun\statistics.php /Autorun_Pin=mypassword /foo=bar

??? Is this how I would do it?
 
Can any help out on the above 2 Q's?

Also, I was still getting errors on

C:\PHP\php.exe C:\mydir\autorun\statistics.php /Autorun_Pin=mypassword

But this worked with just a space before the variable? Which one is the correct syntax?

C:\PHP\php.exe C:\mydir\autorun\statistics.php Autorun_Pin=mypassword

Thanks!
 
If you pass more parameters, $_SERVER['argv'] will have more items in it. But you could easily have known this through experimentation on your own.

Whether or not you put slashes, dashes or something else is entirely a stylistic question that only you can answer.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top