Execute a system command

From Rosetta Code
Revision as of 02:41, 1 February 2007 by MikeMol (talk | contribs) (Created task, added C++, Perl, UNIX Shell)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Execute a system command
You are encouraged to solve this task according to the task description, using any language you may know.

In this task, the goal is to run either the ls system command, or the pause system command.

C++

Compiler: Visual C++ 2005

system("pause");

Perl

Note the use of grave quotes instead of "normal" single quotes.

`ls`

UNIX Shell

UNIX shells are designed to run system commands as a default operation.

ls

If one wants to capture the command's standard output:

CAPTUREDOUTPUT=$(ls)