168

Executing External Commands
The Fork & Exec Functions

  • The fork() function creates a new child process

  • The exec() function overlays (replaces) the active process image with a new executable image

      # Here, do common initialization
      unless ( fork ) {
      	# Here, I'm the child
      	# You may invoke perl commands, and/or the exec() function
      	exec( "ftp ftp.sdsc.edu" ); # This overlays child with ftp
      	# We should never reach this line...
      }
      # Here, I'm the parent