I am trying to run a php script from the command line (I will ultimately trying to run it as a CRON job but I'll get to that later) and I can't figure out how.
My script is very simple

<?
mail("myemail","A Test","A Test");
?>

I am entering this at the command line

php test.php

and getting this result

X-Powered-By: PHP/4.2.2
Content-type: text/html

<?
mail("robert.y@cd-wow.com","A Test","A TEst");
?>

Which seems like it could be right, but I'm not getting the email.
Thanks in advance
Rob

    the result means the scripts is'nt executed.
    if it is executed, u can't see "<? ------ ?>.

    try

    <?php

    mail(------)
    ?>
    good luck

      Excelent, that works beutifully now.
      Thanks caos2003
      Rob

        Right, now on to the cron job. I'm a little scared about this bit because I've never done it before and it's on the company's main server :eek:
        Does this look right for a script that is to be run once a day at 7 am?

        #crontab
        0 7 * * * /usr/bin/php bibbit.php;
        

        Thanks
        Rob

          You wouldn't use a ; a the end.

          And you might want to call it like this:

          0 7 * /usr/bin/php -q /full/path/to/bibbit.php

          The "-q" supresses the "X-Powered-By: PHP/4.2.2 Content-type: text/html" information.

          --Brad Fears

            i have't used cron before,so i'm not very sure.
            however,this will help u.
            0 7 * root php -q x.php

            or
            add "#!/usr/bin/php"in the x.php before "<?php-------"
            and chmod +x x.php
            then u can use

            0 7 * root x.php

            it will work.

            --Chaos

              excellent all done and lovely.
              Thanks guys
              Rob

                Write a Reply...