Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 7th, 2012  |  syntax: None  |  size: 1.53 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Perl: command works from shell but not system()
  2. ERROR: NEWSTACK - NO INPUT FILE SELECTED
  3. sh: line1: ./oldfilename: cannot execute binary file
  4.        
  5. print "Enter the rootname of the files to be converted: ";
  6. my $filename = <STDIN>;
  7. chop $filename;
  8.  
  9. my @files = qx(ls $filename*.mrc);    
  10. open LOGFILE, (">modeconvert-log");    
  11. foreach my $mrc (@files)          
  12. {        
  13. print LOGFILE "$mrc";      
  14. system("newstack -mode 2 $mrc $mrc");    
  15. }
  16. my $fileno = @files;
  17. print "$fileno files convertedn";
  18.        
  19. $ perl -e'system("whon oldfileame newfilename")'
  20. sh: line 1: oldfileame: command not found
  21.        
  22. my @files = qx(ls $filename*.mrc);
  23.        
  24. my @files = qx(ls $filename*.mrc);
  25. chomp @files;
  26.        
  27. my @files = glob("Q$filenameE*.mrc");
  28.        
  29. use IPC::System::Simple qw( system );                          # Replaces system with one that dies on Checks for errors.
  30.  
  31. open(my $LOGFILE, '>', 'modeconvert-log')                      # Avoids global vars.
  32.    or die("Can't create log file "modeconvert-log": $!n");  # Adds useful error checking.
  33.  
  34. print "Enter the rootname of the files to be converted: ";
  35. my $filename = <STDIN>;
  36. chomp $filename;                                               # chomp is safer.
  37.  
  38. my @files = glob("Q$filenameE*.mrc");                        # Works with file names with spaces, etc.
  39.  
  40. for my $mrc (@files) {
  41.    print $LOGFILE "$mrcn";                                    # Was missing a newline.
  42.    system("newstack", "-mode", "2", $mrc, $mrc);               # Works with file names with spaces, etc.
  43. }
  44.  
  45. print 0+@files, " files converted.n";