Note that there are some explanatory texts on larger screens.

plurals
  1. PObash script execution from php and instantaneous output back to webpage
    primarykey
    data
    text
    <p>I have a collection of bash and Perl scripts to </p> <ol> <li>develop a directory structure desired for deployment on linux box</li> <li><em>(optionally)</em> export code from svn </li> <li>build a package from this source</li> </ol> <p>This is working well from terminal. Now my client requests a web interface to this process. </p> <p>e.g "Create New Package" button on certain page will invoke above steps one by one and return the output to user as script echos, not when the whole scripts executes.</p> <p>Is it possible to send instantaneous output from bash script to webpage or php script which has invoked it through program execution functions (system, exec, passthru ... or any thing else that suite this process flow) ?</p> <p>What is elegant why to do this ?</p> <p>What security precautions I should take while doing such thing (if possible)?</p> <p><strong>Edit</strong> After some search I have found part of the solution but still not working :</p> <pre><code>$cmd = 'cat ./password.txt|sudo -S ./setup.sh '; $descriptorspec = array( 0 =&gt; array("pipe", "r"), // stdin is a pipe that the child will read from 1 =&gt; array("pipe", "w"), // stdout is a pipe that the child will write to 2 =&gt; array("pipe", "w") // stderr is a pipe that the child will read from ); flush(); $process = proc_open($cmd, $descriptorspec, $pipes, './', array()); echo "&lt;pre&gt;"; if (is_resource($process)) { while ($s = fgets($pipes[1])) { print "Message:".$s; flush(); } while ($s = fgets($pipes[2])) { print "Error:".$s; flush(); } } echo "&lt;/pre&gt;"; </code></pre> <p><strong>output:</strong> (webpage)</p> <pre><code>Error:WARNING: Improper use of the sudo command could lead to data loss Error:or the deletion of important system files. Please double-check your Error:typing when using sudo. Type "man sudo" for more information. Error: Error:To proceed, enter your password, or type Ctrl-C to abort. Error: Error:Password: Error:Sorry, try again. Error:Password: Error:Sorry, try again. Error:Password: Error:Sorry, try again. Error:sudo: 3 incorrect password attempts** </code></pre> <p>First issue I am having now is to pass sudo passoword </p> <p>help please !</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload