Results 1 to 4 of 4

Thread: Passing PHP variables to bash script

Threaded View

  1. #1
    Join Date
    Jan 2006
    Beans
    51

    Passing PHP variables to bash script

    I am trying to pass variables from php to bash and im not sure how to get this to work. this is what i am trying:

    PHP:
    Code:
    <?php
    echo '<pre>';
    $var1="hello";
    $var2="joe";
    putenv("VAR1=$var1");
    $last_line = system('/home/www/public_html/domain.com/script/ls $var1 $var2', $retval);
    echo '
    </pre>
    <hr />Last line of the output: ' . $last_line . '
    <hr />Return value: ' . $retval;
    ?>
    BASH:
    Code:
    #!/bin/bash
    
    ls
    sudo mkdir test
    sudo chown -R www-data:www-data /home/www/public_html/domain.com/script/test
    echo -e "var1: $1, var2: $1"
    but nothing seems to get passed to bash. I want to be able to do this to create new folders, give ownership and permission changes to those folders, and later create new virtualhosts with a php interface.

    Cheers
    Last edited by craigp; November 13th, 2008 at 07:41 PM.

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
  •