Basic HTML version of Foils prepared Sept 20 97

Foil 72 Execution of UNIX Commands --
Filehandle Mechanism

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


1 open(WHOHANDLE, "who|"); # opens WHOHANDLE for reading output of system call to who
2 the | at right means we will be able to treat output of who as though we were reading it from a file
3 @whosaid = <WHOHANDLE> ; # defines an array whosaid holding output of who command
4 open(LPRHANDLE, "|lpr -Pgcf"); # with | at left opens lpr process so that if we write to filehandle LPRHANDLE it is as though we handed file to input of lpr
  • print LPRHANDLE "This is a test\n"; # for example
5 close(LPRHANDLE); # waits until lpr command has finished and closes handle

in Table To:


© 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 Sun Sep 21 1997