SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Apr 2003
    Location
    delhi
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Suggestion required (PHP running on shell command)

    Hi all,

    Need you help..

    1. Can we run a .php file from a coomand promt of unix.
    so that i can use "crontab" command.
    2. can we read a remote file such as
    http://www.xyz.gov/dhspublic/display?theme=29

    I am able to read a remote file as

    http://www.xyz.gov/index.html

    thanks in advance

    Mukesh

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2002
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1. Yes: as long as you have the CLI installed (To see if you do type: "[nucleuz:~] nucleuz% php -v" in a terminal)
    2. YES, the same way as you do the other remote file

  3. #3
    ********* wombat firepages's Avatar
    Join Date
    Jul 2000
    Location
    Perth Australia
    Posts
    1,717
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the `standard` method would be to cron lynx to run the script

  4. #4
    SitePoint Member
    Join Date
    Apr 2003
    Location
    delhi
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Nucl and fire,
    Thanks alot....yes the url part is solved.but i am still not get the running of a .php file from telnet.
    Nuclez has given me the command but plz make it more clear..

    suupose we have the file in /var/www/html/runonshell.php the how can i run this on linux using telnet.
    Actully i have to execute the script on an given interval.

    Thanks in adv
    mukesh

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2001
    Location
    UK
    Posts
    105
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you included:

    #!/usr/local/php4/bin/php

    at the top of your php file (or whatever the path to your PHP installation is)?

  6. #6

  7. #7
    SitePoint Member
    Join Date
    Apr 2003
    Location
    delhi
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi all,
    thanks alot for thge suggestions.
    I am doing scheduling on server using crontab.
    command: lynx http://www.fdgf.com/index.php
    but its not executing the file.
    Plz help me
    mukesh

  8. #8
    SitePoint Addict Viral's Avatar
    Join Date
    Nov 2001
    Location
    Washington DC
    Posts
    294
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have cli php installed (did you check by typing "php -v" for your prompt as nucleuz suggested?) then you have two choices...

    One, run it as an external file:
    unix>php ./yourfile.php

    or two, at the very top of your php file, add the line that torrent showed:
    #/path/to/your/php

    Then you can chmod it to executable (711) and:
    unix>./yourfile.php

    or add it to your cron:
    0 9 * * * /path/to/yourfile.php would execute it at 9am everyday

    Not sure how else we can help you other than what people have already shared here...

    --Viral
    A computer without Windows is like a chocolate cake without mustard.

  9. #9
    SitePoint Enthusiast BDKR's Avatar
    Join Date
    Sep 2002
    Location
    Clearwater, Florida
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nucleuz
    1. Yes: as long as you have the CLI installed (To see if you do type: "[nucleuz:~] nucleuz% php -v" in a terminal)
    2. YES, the same way as you do the other remote file
    Just to add to this, you can do this with both the CLI AND the CGI sapi installs. CLI makes a couple of things easier, but either way will still work. An example of one of the ways CLI is helpfull concerns getting data from user input (from the keyboard via STDIN). As an example, with the CGI version one needs to do something like this:

    PHP Code:
    <?php
    $ky
    =fopen('php://stdin''r');
    ?>
    Where as with the CLI sapi, php://stdin is a constant (STDIN).

    There is a section of the manual devoted to this. Check it out. It's good stuff. I do a ton of systems level stuff with PHP as my job is mostly DBA / Network / Cluster admin stuff. Who said PHP was just for web development?

    Good luck :-)

    Cheers,
    BDKR
    If you're not on the gas, you're off the gas!


Bookmarks

Posting Permissions

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