Execute a Shell Command
Sometimes in a web application, you may need to execute a system command. Some
users also use Myna in conjunction with Winstone for a small footprint
administration server. This way administration tasks can be can be written
in JavaScript. Using system commands in Myna is very easy to do.
Myna.executeShell(shellCommand,script,waitForOutput)
shellCommand should be the command shell such as "bash" on Linux.
script is your string of commands.
waitForOutput defaults to true. If true, the script will wait for the returned output.
Returns a JavaScript Object with three properties: output,errors,exitCode.
Here is the sample code:
<%
var object = Myna.executeShell('bash','scp -r /home/myna1 /home/myna2');
%>
<%=object.output%><br>
<%=object.errors%><br>
<%=object.exitCode%><br>