0

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.

6
  • 1
    Can you show us what you're entering into the command line? Commented Apr 16, 2011 at 13:57
  • 1
    Can you please post the result of print_r($argv); ? Commented Apr 16, 2011 at 13:58
  • How do you call that programm? What does var_dump($argv) tell you? Commented Apr 16, 2011 at 13:58
  • What comes before? Did you know that $argc contains the same value as count($argv) (the number of arguments) ? Commented Apr 16, 2011 at 13:58
  • Maybe you can check error log file to see if there is some thing wrong or check PHP.ini config Commented Apr 16, 2011 at 14:02

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

4 Comments

just had the same problem. Your answer helped me out. Thanks!
Always love to hear that my scre*ups help other people ;)
Me too... Well, on some doc page of go daddy, it is said to use the other /web/cgi-bin/php version... So thanks for being more useful than go daddy's indications !!
make sure you don't forget this is a pretty old post my friend :). who knows what they changed!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.