Basic HTML version of Foils prepared March 30 97

Foil 78 Execution of UNIX Commands -- Filehandle Mechanism (Chapter 15 of Llama Book)

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


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 as 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 Sat Sep 6 1997