[index] [text page] [<<start] [<prev] [next>] [last>>]
Page 24: System, backticks, open, and exec

Page 24

  
  System, backticks, open, and exec
  Perl offers many ways to call external programs
  # launch an editor for the user
  my $EDITOR = $ENV{VISUAL} || $ENV{EDITOR} || 'vi';
  system( "vi $tmpfile" );
  # Find the user accessing /tmp/somefile
  my $abuser = `/bin/fuser /tmp/somefile`;
  # ROT13 decode the userinput
  open ROT13, "|rot13";
  print ROT13 $userinput;
  close ROT13;
  # stop our perl script entirely, run something else
  exec "/usr/bin/nmap -A www.microsoft.com"

Copyright 2003, Bri Hatch of Onsight, Inc.

Presented at SPUG, 2003.

Presentation created using vim and MagicPoint.