S
Scott Bass
Active State Perl 5.8
Windoze
I'm trying to write a simple script that will glob all files with a
particular extension, then run a system command against each file. I want
the script to fork off a process for each invocation, and not wait for the
system command to finish.
Here is what I have so far:
#!perl
# set pragmas
use strict;
use warnings;
# define SAS command string(s)
my ($SAS,$args);
# SAS 8
$SAS = q("C:/Program Files/SAS Institute/SAS/V8/sas.exe" -CONFIG "C:/Program
Files/SAS Institute/SAS/V8/SASV8.CFG");
# SAS 9
$SAS = q("C:/Program Files/SAS/SAS 9.1/sas.exe" -CONFIG "C:/Program
Files/SAS/SAS 9.1/nls/en/SASV9.CFG");
# the rest of the options
$args =
q( -rsasuser -icon -nosplash -batch -noterminal -no$syntaxcheck -initstmt
"%include '../init.sas';" -sysin );
# include desired modules
use Getopt::Long;
use File::Basename;
# process command line options
my $debug = '0';
GetOptions ('debug!' => \$debug);
# glob files specified on the command line
my @files;
while (@ARGV) {
push @files, glob(shift @ARGV);
}
# process each file
my ($dirname, $basename);
while (@files) {
$_ = shift @files;
$basename = basename($_);
$dirname = dirname($_);
my @cmd = ( "$SAS $args $basename" );
if (! $debug) {
chdir($dirname);
exec { $cmd[0] } @cmd;
}
else {
print "cd $dirname\n";
print @cmd,"\n";
}
}
exit;
It's failing on line 44 (exec command). I've read the doc
file:///C:/Perl/html/lib/Pod/perlfunc.html, exec command, but am still
having problems.
Thanks,
Scott
Windoze
I'm trying to write a simple script that will glob all files with a
particular extension, then run a system command against each file. I want
the script to fork off a process for each invocation, and not wait for the
system command to finish.
Here is what I have so far:
#!perl
# set pragmas
use strict;
use warnings;
# define SAS command string(s)
my ($SAS,$args);
# SAS 8
$SAS = q("C:/Program Files/SAS Institute/SAS/V8/sas.exe" -CONFIG "C:/Program
Files/SAS Institute/SAS/V8/SASV8.CFG");
# SAS 9
$SAS = q("C:/Program Files/SAS/SAS 9.1/sas.exe" -CONFIG "C:/Program
Files/SAS/SAS 9.1/nls/en/SASV9.CFG");
# the rest of the options
$args =
q( -rsasuser -icon -nosplash -batch -noterminal -no$syntaxcheck -initstmt
"%include '../init.sas';" -sysin );
# include desired modules
use Getopt::Long;
use File::Basename;
# process command line options
my $debug = '0';
GetOptions ('debug!' => \$debug);
# glob files specified on the command line
my @files;
while (@ARGV) {
push @files, glob(shift @ARGV);
}
# process each file
my ($dirname, $basename);
while (@files) {
$_ = shift @files;
$basename = basename($_);
$dirname = dirname($_);
my @cmd = ( "$SAS $args $basename" );
if (! $debug) {
chdir($dirname);
exec { $cmd[0] } @cmd;
}
else {
print "cd $dirname\n";
print @cmd,"\n";
}
}
exit;
It's failing on line 44 (exec command). I've read the doc
file:///C:/Perl/html/lib/Pod/perlfunc.html, exec command, but am still
having problems.
Thanks,
Scott