5
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()

Process Management

  • Upload
    kizzy

  • View
    18

  • Download
    0

Embed Size (px)

DESCRIPTION

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(). - PowerPoint PPT Presentation

Citation preview

Page 1: 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()

Page 2: Process Management

system()

• Argument specifies the program to runsystem( “date” );

• Runs the command and returns the exit status of the programsystem( “data” ) && die “bad command”;

• Standard input, standard output, and standard error are inherited

Page 3: Process Management

Fancy Stuff

• This all workssystem( “date > date.out” );

$fileName = “date.out”;

system( “date > $fileName” );

system ( “dir process.perl” );

system ( “dir”, “process.perl” );

Page 4: Process Management

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;

Page 5: Process Management

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.