Execute a system command: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
Line 243: Line 243:
=={{header|AppleScript}}==
=={{header|AppleScript}}==
<lang applescript>do shell script "ls" without altering line endings</lang>
<lang applescript>do shell script "ls" without altering line endings</lang>

=={{header|Applesoft BASIC}}==
=={{header|Applesoft BASIC}}==
<lang ApplesoftBASIC>? CHR$(4)"CATALOG"</lang>
<lang ApplesoftBASIC>? CHR$(4)"CATALOG"</lang>
Line 334: Line 335:
return 0;
return 0;
}</lang>
}</lang>

=={{header|C++}}==
{{works with|Visual C++|2005}}
<lang cpp>system("pause");</lang>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==
Line 365: Line 362:
}
}
}</lang>
}</lang>

=={{header|C++}}==
{{works with|Visual C++|2005}}
<lang cpp>system("pause");</lang>

=={{header|Clojure}}==
=={{header|Clojure}}==


Line 471: Line 473:
=={{header|dc}}==
=={{header|dc}}==
<lang dc>! ls</lang>
<lang dc>! ls</lang>

=={{header|DCL}}==
=={{header|DCL}}==
<lang DCL>Directory</lang>
<lang DCL>Directory</lang>
Line 702: Line 705:
...
...
</pre>
</pre>

=={{header|gnuplot}}==

<lang gnuplot>!ls</lang>


=={{header|Go}}==
=={{header|Go}}==
Line 720: Line 727:
}
}
}</lang>
}</lang>

=={{header|gnuplot}}==

<lang gnuplot>!ls</lang>


=={{header|Groovy}}==
=={{header|Groovy}}==
Line 767: Line 770:
pid := system(command_string,&input,&output,&errout,"nowait")
pid := system(command_string,&input,&output,&errout,"nowait")
</lang>
</lang>

=={{header|IDL}}==
=={{header|IDL}}==
<lang idl>$ls</lang>
<lang idl>$ls</lang>
Line 1,023: Line 1,027:
> (io:format (os:cmd "ls -alrt"))
> (io:format (os:cmd "ls -alrt"))
</lang>
</lang>



=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
Line 1,030: Line 1,033:
run "cmd.exe /";drive1$;" dir & pause"
run "cmd.exe /";drive1$;" dir & pause"
</lang>
</lang>

=={{header|Lingo}}==
{{libheader|Shell Xtra}}
<lang lingo>sx = xtra("Shell").new()
if the platform contains "win" then
put sx.shell_cmd("dir")
else
put sx.shell_cmd("ls")
end if</lang>


=={{header|Limbo}}==
=={{header|Limbo}}==
Line 1,072: Line 1,066:


It's not strictly necessary to pass the graphics context to ls, but it is generally a good idea to do so when calling another program.
It's not strictly necessary to pass the graphics context to ls, but it is generally a good idea to do so when calling another program.

=={{header|Lingo}}==
{{libheader|Shell Xtra}}
<lang lingo>sx = xtra("Shell").new()
if the platform contains "win" then
put sx.shell_cmd("dir")
else
put sx.shell_cmd("ls")
end if</lang>


=={{header|Locomotive Basic}}==
=={{header|Locomotive Basic}}==
Line 1,206: Line 1,209:
M3toC.FreeCopiedS(command);
M3toC.FreeCopiedS(command);
END Exec.</lang>
END Exec.</lang>

=={{header|MUMPS}}==
=={{header|MUMPS}}==
<p>ANSI MUMPS doesn't allow access to the operating system except possibly through the View command and $View function, both of which are implementation specific. Intersystems' Caché does allow you to create processes with the $ZF function, and if the permissions for the Caché process allow it you can perform operating system commands.</p>
<p>ANSI MUMPS doesn't allow access to the operating system except possibly through the View command and $View function, both of which are implementation specific. Intersystems' Caché does allow you to create processes with the $ZF function, and if the permissions for the Caché process allow it you can perform operating system commands.</p>
Line 1,368: Line 1,372:
ExecuteProcess('/bin/ls', '-alh');
ExecuteProcess('/bin/ls', '-alh');
end.</lang>
end.</lang>

=={{header|Perl}}==
<lang perl>my @results = qx(ls); # run command and return STDOUT as a string

my @results = `ls`; # same, alternative syntax

system "ls"; # run command and return exit status; STDOUT of command goes program STDOUT

print `ls`; # same, but with back quotes

exec "ls"; # replace current process with another</lang>

See also:
http://perldoc.perl.org/perlipc.html#Using-open()-for-IPC
http://perldoc.perl.org/IPC/Open3.html

=={{header|Perl 6}}==
<lang perl6>run "ls" orelse .die; # output to stdout

my @ls = qx/ls/; # output to variable

my $cmd = 'ls';
@ls = qqx/$cmd/; # same thing with interpolation</lang>


=={{header|PDP-11 Assembly}}==
=={{header|PDP-11 Assembly}}==
Line 1,457: Line 1,438:
...
...
.cmd_ls EQUS "ls",0</lang>
.cmd_ls EQUS "ls",0</lang>

=={{header|Perl}}==
<lang perl>my @results = qx(ls); # run command and return STDOUT as a string

my @results = `ls`; # same, alternative syntax

system "ls"; # run command and return exit status; STDOUT of command goes program STDOUT

print `ls`; # same, but with back quotes

exec "ls"; # replace current process with another</lang>

See also:
http://perldoc.perl.org/perlipc.html#Using-open()-for-IPC
http://perldoc.perl.org/IPC/Open3.html


=={{header|Phix}}==
=={{header|Phix}}==
Line 1,520: Line 1,516:
{{works with|GNU Prolog}}
{{works with|GNU Prolog}}
<lang prolog>shell('ls').</lang>
<lang prolog>shell('ls').</lang>

=={{header|PureBasic}}==
=={{header|PureBasic}}==
<lang PureBasic>ImportC "msvcrt.lib"
<lang PureBasic>ImportC "msvcrt.lib"
Line 1,584: Line 1,581:
(system* (find-executable-path "/bin/ls") "-l")
(system* (find-executable-path "/bin/ls") "-l")
</lang>
</lang>

=={{header|Raku}}==
(formerly Perl 6)
<lang perl6>run "ls" orelse .die; # output to stdout

my @ls = qx/ls/; # output to variable

my $cmd = 'ls';
@ls = qqx/$cmd/; # same thing with interpolation</lang>


=={{header|Raven}}==
=={{header|Raven}}==
Line 1,715: Line 1,721:


<lang smalltalk>Smalltalk system: 'ls'.</lang>
<lang smalltalk>Smalltalk system: 'ls'.</lang>

=={{header|Standard ML}}==
Just run the command:

<lang sml>OS.Process.system "ls"</lang>


=={{header|SQL PL}}==
=={{header|SQL PL}}==
Line 1,745: Line 1,746:
!dir
!dir
</lang>
</lang>

=={{header|Standard ML}}==
Just run the command:

<lang sml>OS.Process.system "ls"</lang>


=={{header|Stata}}==
=={{header|Stata}}==
Line 1,992: Line 1,998:
End Module
End Module
</lang>
</lang>

=={{header|Wart}}==
=={{header|Wart}}==
<lang wart>system "ls"</lang>
<lang wart>system "ls"</lang>