Basic HTML version of Foils prepared March 30 97

Foil 77 Execution of UNIX Commands -- backquotes (Chapter 15 of Llama Book)

From PERL4 Tutorial for CPS616 Computational Science for Information Age Course CPS616 -- February 1995. by Geoffrey C. Fox


$now= "Todays date: " . `date`; # sets $now to be the specified label followed by result of shell's date invocation
`who` would naturally return a set of lines and the result can be stored into an array -- one array entry for each output line
Both system and backquote mechanism invoke a shell command which normally share standard input, standard output and standard error with the Perl program
This can be reset as for instance in
`rm fred 2>&1`; # using shell syntax to send standard error to same place as standard output



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Sep 6 1997