1 / 5

Process Management

Process Management. As a scripting language Perl provides the ability to run programs inside a Perl script. For example I could run a “dir” command inside of Perl, munge the output, and print my own version of it You do this using system() exec(). system().

kizzy
Download Presentation

Process Management

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Process Management • As a scripting language Perl provides the ability to run programs inside a Perl script. • For example I could run a “dir” command inside of Perl, munge the output, and print my own version of it • You do this using • system() • exec()

  2. system() • Argument specifies the program to run system( “date” ); • Runs the command and returns the exit status of the program system( “data” ) && die “bad command”; • Standard input, standard output, and standard error are inherited

  3. Fancy Stuff • This all works system( “date > date.out” ); $fileName = “date.out”; system( “date > $fileName” ); system ( “dir process.perl” ); system ( “dir”, “process.perl” );

  4. Processes and File Handles • Processes can be started from within file handles • open( DIRPROC, “dir|” ); • All the standard file stuff now applies to the output • @listing=<DIRPROC>; • open( LPR, “|lpr”); • print LPR @listing;

  5. Your Turn!! • Write a Perl script that prints out the names of the directories and then the names of a the files in the current directory.

More Related