running bash scripts in php

Posted by HDawg on Stack Overflow See other posts from Stack Overflow or by HDawg
Published on 2010-03-29T18:31:25Z Indexed on 2010/03/29 18:33 UTC
Read the original article Hit count: 483

Filed under:
|
|
|

I have two computers. On the first computer I have apache running with all my web code. On the second computer I have large amounts of data stored with a retrieval script (the script usually takes hours to run). I am essentially creating a web UI to access this data without any time delay.

so I call:

exec("bash initial.bash");

this is a driver script that is in my Apache folder. It calls the script on the other computer. calling: ssh otherMachine temp.bash&

this script invokes the data retrieval script on the second computer.

If I call initial.bash in the terminal, everything works smoothly and successfully, but if I call it in my PHP file, then all my commands in initial.bash run, with the exception of ssh otherMachine temp.bash&. I put the & at the end of that, so that temp.bash will run in the background, since it does take a few hours to complete.

I am not sure why the nested script is not running when invoked by Apache. Is there a better alternative than using exec or shell_exec to call a script, which ultimately calls another script. The reason I don't call a script on the second machine directly is because of the time it takes the program to run. Shell_exec does not render the php page until the script is complete.

© Stack Overflow or respective owner

Related posts about php

Related posts about shell-exec

  • R: ESS shell.exec speed

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I am using ESS in Windows XP. I have noticed that shell.exec is much slower with ESS than with RGui (the problem occurs when I try help(ls) for example, the help is displayed much faster in RGui, I tracked it down and it is due to shell.exec). Is there any reason for this? How can I fix it? My default… >>> More

  • shell_exec() in PHP

    as seen on Stack Overflow - Search for 'Stack Overflow'
    <?php // Execute a shell script $dump = shell_exec('bigfile.sh'); // This script takes some 10s to complete execution print_r($dump); // Dump log to screen ?> When the script above is executed from the browser, it loads for 10s and the dumps the output of the script to the screen. This… >>> More

  • running bash scripts in php

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I have two computers. On the first computer I have apache running with all my web code. On the second computer I have large amounts of data stored with a retrieval script (the script usually takes hours to run). I am essentially creating a web UI to access this data without any time delay. so I… >>> More

  • shell_exec() Doesn't Show The Output

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I'm doing a PHP site that uses a shell_exec() function like this: $file = "upload/" . $_FILES["file"]["name"]; $output = shell_exec("leaf $file"); echo "<pre>$output</pre>"; Where leaf is a program that is located in the same directory of my script, but when I tried to run this script… >>> More

  • System_Daemon and shell_exec

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hey Everyone, I've set up a daemon (daemon.php) using PEAR's System_Daemon which waits for something to appear in the database. Once something is there, the daemon gets enough information and sends it out to another script (execute.php) using the shell_exec command this way I'm not worried about… >>> More