Find the answer to your Linux question:
Results 1 to 3 of 3
what the command should i use to run script file from command line?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    38

    run php from command line


    what the command should i use to run script file from command line?

  2. #2
    Linux Engineer Kieren's Avatar
    Join Date
    Aug 2007
    Location
    England
    Posts
    848
    If you have PHP installed use the command:

    Code:
    php <php script>
    where <php script> is the name of the PHP script you would like to run.
    Linux User #453176

  3. #3
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Slackware, {Free, Open, Net}BSD, Solaris
    Posts
    1,288
    Hi.

    You can use:
    Code:
    #!/usr/local/bin/php
    <?php
    
    #  @(#) s1      Demonstrate one way to call php.
    // @(#) s1      Demonstrate one way to call php.
    
    print "\n";
    print " Hello, world from php.\n";
    print "\n";
    
    ?>
    Producing:
    Code:
    % ./s1
    
     Hello, world from php.
    Noted by:
    You can use a shebang line to automatically invoke php from scripts.
    Only the CLI version of PHP will ignore such a first line as shown
    below:

    #!/bin/php
    <?php
    // your script
    ?>

    -- excerpt from man php on a FreeBSD 6.2-RELEASE-p1 system
    cheers, drl
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

Posting Permissions

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