home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SATAN11.ZIP / PERL / SHELL.PL < prev    next >
Text File  |  1995-04-11  |  752b  |  37 lines

  1. #
  2. # Run a command with extreme prejudice and make sure it finishes.
  3. #
  4. #
  5. # version 1, Mon Mar 20 14:09:35 1995, last mod by wietse
  6. #
  7.  
  8. require 'config/paths.pl';
  9. require 'perl/status.pl';
  10.  
  11. sub bad_cmd {
  12.     local($command) = @_;
  13.  
  14.     return ($command =~ /[^-_ ,a-zA-Z0-9:.!\/]/);
  15. }
  16.         
  17. sub open_cmd {
  18.     local($handle, $timeout, $command) = @_;
  19.     local($ret, $shell_cmd);
  20.  
  21.     $shell_cmd = "$TIMEOUT $timeout $command";
  22.  
  23.     if (&bad_cmd($shell_cmd)) {
  24.         print "==> NOT RUNNING $shell_cmd (illegal characters)\n";
  25.     } elsif ($debug) {
  26.         $ret = open($handle, "$shell_cmd 2>/dev/null|");
  27.     } else {
  28.         $ret = open($handle, "$shell_cmd|");
  29.     }
  30.     &update_status("$shell_cmd");
  31.     print "==> running $shell_cmd\n" if $debug;
  32.     return $ret;
  33. }
  34.  
  35. 1;
  36.  
  37.