
Untitled
By: a guest on
Aug 7th, 2012 | syntax:
None | size: 1.53 KB | hits: 9 | expires: Never
Perl: command works from shell but not system()
ERROR: NEWSTACK - NO INPUT FILE SELECTED
sh: line1: ./oldfilename: cannot execute binary file
print "Enter the rootname of the files to be converted: ";
my $filename = <STDIN>;
chop $filename;
my @files = qx(ls $filename*.mrc);
open LOGFILE, (">modeconvert-log");
foreach my $mrc (@files)
{
print LOGFILE "$mrc";
system("newstack -mode 2 $mrc $mrc");
}
my $fileno = @files;
print "$fileno files convertedn";
$ perl -e'system("whon oldfileame newfilename")'
sh: line 1: oldfileame: command not found
my @files = qx(ls $filename*.mrc);
my @files = qx(ls $filename*.mrc);
chomp @files;
my @files = glob("Q$filenameE*.mrc");
use IPC::System::Simple qw( system ); # Replaces system with one that dies on Checks for errors.
open(my $LOGFILE, '>', 'modeconvert-log') # Avoids global vars.
or die("Can't create log file "modeconvert-log": $!n"); # Adds useful error checking.
print "Enter the rootname of the files to be converted: ";
my $filename = <STDIN>;
chomp $filename; # chomp is safer.
my @files = glob("Q$filenameE*.mrc"); # Works with file names with spaces, etc.
for my $mrc (@files) {
print $LOGFILE "$mrcn"; # Was missing a newline.
system("newstack", "-mode", "2", $mrc, $mrc); # Works with file names with spaces, etc.
}
print 0+@files, " files converted.n";