PHP system() call with variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cameron@rockefeller.edu

    PHP system() call with variables

    I'm looking to use the system (or exec) function to call a shell
    script in UNIX. The following is the UNIX command line without PHP:

    /home/public_html/VariableDirecto ry/myScript.ksh

    VariableDirecto ry can be a number of different directories. Each of
    them contain a copy of myScript.ksh.
    So, we run the same script in different directories like this:

    /home/public_html/FirstDirectory/myScript.ksh
    and
    /home/public_html/SecondDirectory/myScript.ksh

    Now, regarding PHP:
    I'm looking to have the web-user decide in which VariableDirecto ry
    he/she wants to run myScript.ksh. Therefore, I'm looking to have a
    system() call which looks something like the following:

    system("/home/public_html/'".$_REQUEST[directory]."'/myScript.ksh");

    However, this doesn't work. I've also tried to save
    $_REQUEST[directory] as another variable and call it within the path.
    For example,

    $theDir = `echo $_REQUEST[directory]`;
    system("/home/public_html/$theDir/myScript.ksh");

    This doesn't work either. Does anyone know about the syntax for this
    example of a system() call?

    Thanks,
    Cam
  • CountScubula

    #2
    Re: PHP system() call with variables

    <cameron@rockef eller.edu> wrote in message
    news:1888952f.0 401220952.39a71 e40@posting.goo gle.com...[color=blue]
    > I'm looking to use the system (or exec) function to call a shell
    > script in UNIX. The following is the UNIX command line without PHP:
    >
    > /home/public_html/VariableDirecto ry/myScript.ksh
    >
    > VariableDirecto ry can be a number of different directories. Each of
    > them contain a copy of myScript.ksh.
    > So, we run the same script in different directories like this:
    >
    > /home/public_html/FirstDirectory/myScript.ksh
    > and
    > /home/public_html/SecondDirectory/myScript.ksh
    >
    > Now, regarding PHP:
    > I'm looking to have the web-user decide in which VariableDirecto ry
    > he/she wants to run myScript.ksh. Therefore, I'm looking to have a
    > system() call which looks something like the following:
    >
    > system("/home/public_html/'".$_REQUEST[directory]."'/myScript.ksh");
    >
    > However, this doesn't work. I've also tried to save
    > $_REQUEST[directory] as another variable and call it within the path.
    > For example,
    >
    > $theDir = `echo $_REQUEST[directory]`;
    > system("/home/public_html/$theDir/myScript.ksh");
    >
    > This doesn't work either. Does anyone know about the syntax for this
    > example of a system() call?
    >
    > Thanks,
    > Cam[/color]

    try putting a . in front and have the file set to 755 as in:

    $theDir = `echo $_REQUEST[directory]`;
    system("./home/public_html/$theDir/myScript.ksh");


    or try

    $theDir = `echo $_REQUEST[directory]`;
    system("/bin/ksh /home/public_html/$theDir/myScript.ksh");


    --
    Mike Bradley
    http://www.gzentools.com -- free online php tools


    Comment

    Working...