Execute a system command: Difference between revisions
Content added Content deleted
No edit summary |
m (→{{header|Phix}}: added syntax colouring, marked p2js incompatible) |
||
Line 1,522: | Line 1,522: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
<!--<lang Phix>(notonline)--> |
|||
<lang Phix>string cmd = iff(platform()=WINDOWS?"dir":"ls") |
|||
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> |
|||
system(cmd) |
|||
<span style="color: #004080;">string</span> <span style="color: #000000;">cmd</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()=</span><span style="color: #004600;">WINDOWS</span><span style="color: #0000FF;">?</span><span style="color: #008000;">"dir"</span><span style="color: #0000FF;">:</span><span style="color: #008000;">"ls"</span><span style="color: #0000FF;">)</span> |
|||
integer res = system_exec("pause",4)</lang> |
|||
<span style="color: #7060A8;">system</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cmd</span><span style="color: #0000FF;">)</span> |
|||
<span style="color: #004080;">integer</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">system_exec</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"pause"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">4</span><span style="color: #0000FF;">)</span> |
|||
<!--</lang>--> |
|||
system_exec allows you to specify whether you want a command shell or not, and whether to wait for a result. In the case of pause, the 4 signifies that we need a shell and we want to wait for it to complete. |
system_exec allows you to specify whether you want a command shell or not, and whether to wait for a result. In the case of pause, the 4 signifies that we need a shell and we want to wait for it to complete. |
||