#1
  1. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Jun 2011
    Posts
    6
    Rep Power
    0

    Question How to call Linux command within PHP?


    How to call Linux command within PHP?
  2. #2
  3. No Profile Picture
    Contributing User
    SEO Chat Skiller (1500 - 1999 posts)

    Join Date
    Jan 2008
    Posts
    1,834
    Rep Power
    427
    Looks like you use backticks `

    http://www.rvdavid.net/execute-linux-commands-in-php-by-using-backticks/
  4. #3
  5. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    8
    Rep Power
    0
    You can execute linux commands within a php script – all you have to do is put the command line in backticks (`).

    Recently, I had to upload an archive to a server which did not allow ssh. For files that I need to transfer, I just package them up in a neat archive and transfer the archive file via scp. Not having ssh access however, I uploaded the archive file via ftp and created a script which extracts the file the file looks like the following:

    <?php
    #extractarchive.php
    echo `tar -xvfz somearchive.tar.gz`;
    ?>

    Upon loading up “extractarchive.php”, I can see the output of the tar command through the browser. I did this by using the echo function on the backticked command line – this is not necessary for the backticked command to be executed by php.

    Of course, the PHP file will need to have the necessary permissions to execute commands and as always, proceed with caution. I myself do not like doing things this way, I’ve used it in the past as a last resort. But if you ever need to do something like this, at least you know that this can be done with PHP.
  6. #4
  7. No Profile Picture
    Registered User
    SEO Chat Explorer (0 - 99 posts)

    Join Date
    Dec 2012
    Location
    banglore
    Posts
    3
    Rep Power
    0
    <?php shell-exe('1s');?>

Similar Threads

  1. Windows vs. Linux: Time to Call a Truce? (PC Magazine)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: Jun 12th, 2006, 07:06 PM
  2. Call Issued For More Mobile Linux Apps (TechWeb)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: Feb 14th, 2006, 03:05 AM
  3. Site coding and the extention use - help
    By jrothra in forum SEO Help (General Chat)
    Replies: 14
    Last Post: Aug 10th, 2005, 02:30 PM
  4. how to 301 redirect dynamic PHP pages.
    By wannabrich in forum Google Optimization
    Replies: 6
    Last Post: Jun 9th, 2005, 11:38 PM
  5. php or htm
    By Steve W in forum Google Optimization
    Replies: 3
    Last Post: Mar 23rd, 2005, 12:43 AM

IMN logo majestic logo threadwatch logo seochat tools logo