Find the answer to your Linux question:
Results 1 to 5 of 5
I have a script on my site that creates a sitemap, and I want to run it weekly. In order to prevent unauthorized use of the script, it requires a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2012
    Posts
    2

    cron command with an argument


    I have a script on my site that creates a sitemap, and I want to run it weekly. In order to prevent unauthorized use of the script, it requires a "token" when the file is called. When the cron command line reads:

    /web/cgi-bin/php5 "/home/html/cgi-bin/sitemapxml.php"

    I get "Incorrect Start Security Token" error, just like I am supposed to. But when the cron command line reads:

    /web/cgi-bin/php5 "/home/html/cgi-bin/sitemapxml.php token=xxxxxx"

    I get "Status: 404 Not Found Content-type: text/html No input file specified."

    How do you properly add arguments to a cron command line? I actually have more than one that needs to be added.
    Last edited by MRusty; 12-12-2012 at 11:49 PM. Reason: typo

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    661
    Quote Originally Posted by MRusty View Post
    I have a script on my site that creates a sitemap, and I want to run it weekly. In order to prevent unauthorized use of the script, it requires a "token" when the file is called. When the cron command line reads:

    /web/cgi-bin/php5 "/home/html/cgi-bin/sitemapxml.php"

    I get "Incorrect Start Security Token" error, just like I am supposed to. But when the cron command line reads:

    /web/cgi-bin/php5 "/home/html/cgi-bin/sitemapxml.php token=xxxxxx"

    I get "Status: 404 Not Found Content-type: text/html No input file specified."

    How do you properly add arguments to a cron command line? I actually have more than one that needs to be added.
    Since you put the following in quotes, it is treated as a single argument (and I believe you want two args):
    Code:
    /home/html/cgi-bin/sitemapxml.php  token=xxxxxx
    If you were running it from the command line would you be executing:
    Code:
    /web/cgi-bin/php5   /home/html/cgi-bin/sitemapxml.php   token=xxxxxx
    Then remove the quotes and use:
    Code:
    /web/cgi-bin/php5 /home/html/cgi-bin/sitemapxml.php   token=xxxxxx
    Also realize that the environment is usually contains less when running in cron.

  3. #3
    Just Joined!
    Join Date
    Dec 2012
    Posts
    2
    Thank you so much alf55!

    All I needed to do was remove the quotes. I have allowed my ISP's cron manager wizzrd "Browse" button to create the command line, and it screwed it up.



    But I am not exactly sure what you meant by: "Also realize that the environment is usually contains less when running in cron. "

  4. $spacer_open
    $spacer_close
  5. #4
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,410
    He meant, that an interactive shell potentially has a different env than cron. Think $PATH, etc
    So a script that runs fine manually can behave differently via cron.
    Last edited by Irithori; 12-14-2012 at 08:38 AM. Reason: typo
    You must always face the curtain with a bow.

  6. #5
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    661
    Thanks for the reply Irithori, I could not have said it better.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •