Reputation: 2555
I created a small script I use for 'cleaning' sitemap file from certain links. I think I used it before with no problems, but am unable to use it now because of a strange bug - no command line params are read at all.
I'm probably looking at the wrong place, but I googled and all I get is the usage I'm implementing already.
Please check the following code snippet:
if(count($argv) != 4) {
echo "\n\nUSAGE: php cleanSitemap.php <input file> <output file> <bad str>\n"
."This script parses <input file>, skipping all the sitemap XML elements containing <bad str>,\n"
."writting only 'good' XML elements into sitemap.\n"
."Sample: php cleanSitemap.php sitemap.xml sitemap_clean.xml protect-x\n"
."\n";
echo "You entered " . count($argv) . " parameters.\n";
exit();
}
What do you think, where is the problem???
EDIT: To simplify things, I created test.php with following content:
<?php
echo count($argv) ."\n";
print_r($argv);
echo "\n";
?>
-bash-3.2$ /web/cgi-bin/php5 test.php 1 2 3 45
Content-type: text/html
0
Ok... While writing this, I think I may have come to something: this is php5 client used on Godaddy shared hosting. Maybe it's somehow set not to be used via command line? Or, if used, it's not accepting command line arguments.
Upvotes: 0
Views: 1564
Reputation: 2555
Ohhhhhhhhhhh... Ok, I'm a total noob.
I have just found out that this problem was really related to the use of the incorrect php binary... Namely, the 'right' one could be found in /usr/local/php5/bin/php
.
I'm really sorry for this mistake.
Upvotes: 3