PDA

View Full Version : $argc and $argv are empty when running spider.php from the shell


bsw114
02-10-2004, 08:48 PM
When trying to index from the shell by passing in a file of URLs the engine bails without indexing. I realized that the $argc and $argv values were empty. Perhaps the implementation depends on some PHP setting such as register_argc_argv=on. Regardless of why this happens, an easy fix is to just assign them from the $_SERVER array and all appears to work fine... Can somebody roll this into the spider.php script?

$argc = $_SERVER["argc"];
$argv = $_SERVER["argv"];

Charter
02-20-2004, 08:52 AM
Hi. Yes, register_argc_argv should be set to on for $argc and $argv to be available from shell. From php.net (http://www.php.net/reserved.variables) is the following:

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the webserver. There is no guarantee that every webserver will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the CGI 1.1 specification, so you should be able to expect those.