Execute a system command: Difference between revisions

(Added Toka)
Line 210:
'''Interpreter:''' [[Perl]]
 
my $@results = `qx(ls`);
Note the use of grave quotes (or back ticks) instead of "normal" single quotes or the qx() command.
# runs command and returns its STDOUT
my $results = `ls`;
my $@results = qx(`ls)`;
# dito, alternative syntax
 
Back ticks as above returns the results, system as below does not.
system "ls";
# runs command and returns its exit status
exec "ls";
# replace current process with another
Also see:
http://perldoc.perl.org/perlipc.html#Using-open()-for-IPC
http://perldoc.perl.org/IPC/Open3.html
 
==[[PHP]]==
Anonymous user