Hi Jono,

This does help thanks for sharing!

Scott

On 7/17/08, Jono Woodhouse <[EMAIL PROTECTED]> wrote:
>
> Hi Scott
>
> We've tried a number of different ways of calling system commands, and
> found that when using sqlite3 (via PHP's PDO drivers) that it was tricky to
> get right on the foxboard. In the end I used the following function that
> worked as long as it was called before any of the SQLite3 functions. Your
> situation may be quite different though..... and hopefully you can use the
> normal system commands without needing to use the following..... but here it
> is for reference:
>
> <?php function systemcmd_ex($commandstr)
> {
>     $pid = pcntl_fork();
>     if ($pid == -1) {
>         die('could not fork');
>     } else if ($pid) {
>         // we are the parent
>         pcntl_waitpid($pid, $status); //Protect against Zombie children
>         return($status);
>     } else {
>         // we are the child
>         // Use pcnl_exec
>         $args = array ($commandstr);
>         pcntl_exec("/var/local/www/quiet.sh", $args);
>         exit(-1); // should never get here!!
>     }
> }
> ?>
>
> You'll also need to create a quiet.sh script (also with chmod +x) - you may
> want it in another location - just remember to change the reference to it's
> path above too.
> which has the following 2 lines in it (remember to use UNIX (and not DOS)
> encoding for this file):
> #!/bin/sh
> $@ > /dev/null 2>&1
>
>
> We are configuring php (v5.2.6) with the following options:
>     --disable-all \
>     --with-config-file-path=/etc/ \
>     --enable-pdo \
>     --enable-session \
>     --with-pdo-sqlite \
>     --enable-posix \
>     --enable-pcntl \
>     --enable-discard-path
>
>
> Cheers
> Jono
>
> Scott Lingerfelt wrote:
>
> I have been successfull sending arguments to a shell script from a php
> web page but cannot get them to be passed to the system.
>
> How can I have an interface in php and have the user set the date and
> submit allowing it to update the system date and time?
>
> Here is a simple php test page:
> [code]
> <?php
> $cmd=070600002008.00 //test date/time
>
> $output = shell_exec('/mnt/flash/date_set.sh '.$cmd);
> echo "<pre>$output</pre>";
> ?>
> [/code]
>
> and here is the script date_set.sh:
> [code]
> var1=$1
> echo 'date ' . $var1
> [/code]
>
> Thanks in advance,
>
> Scott
>
> 
>

Reply via email to