regex - No such file or directory at - Perl dead file closes program -
they want me create feed catalog, table of jobs autosys
, infiles , outfiles jobs depend upon.
the idea that, instead of calling boss @ 3:00am when job fails, level 1 can match failed job file, or vice versa, , fix issue.
the script takes in autosys
config file, takes out executable
line, substrings it, opens file, , regexes out path line. works fine except gasses out when can't open file.
i getting error.
dead file handle no such file or directory @ ./slurp_autosys_config.justexec2 line 10, <$autosys_fh> line 352.
#!/usr/bin/perl use strict; use warnings; open $autosys_fh, '<', "/data/autosys-us.cfg" or die "can't open file $!"; while ( $cfg_line = <$autosys_fh> ) { if ($cfg_line =~ /executable/) { $cut_cfg_line = substr "$cfg_line", 13; if ( $cut_cfg_line =~ /(\/\s*\.[sh,pl,ksh])/ ) { chomp($cut_cfg_line); open $fh_cut_cfg, '<', $cut_cfg_line or die "dead file handle $!"; while ( $path = <$fh_cut_cfg> ) { if ( $path =~ /(\"\/\s*)\"/ ) { print "$cut_cfg_line ---> $path"; sleep 1; } } } } }
this results. want
walt@host:~/walt $ ./slurp_autosys_config.justexec2 /data/adp/ubss/adploggerubss.sh.new ---> dir="/data/scripts" /data/evtusbucgediloader.sh ---> $out="/data/px"; /data/evtusbucgediloader.sh ---> $in="/data/infile"; /data/cboe_xml_hack_check.pl ---> $xml="/data/c4symbolgroupdefconfig.xml"; /data/cboe_xml_hack_check.pl ---> $xml="/data/qedefconfig.xml"; /data/webdownloads/getcboe_bc_csv.pl ---> $reallysave = "/data/bcallclasses.csv"; /data/webdownloads/getcboe_bc_csv.pl ---> $save = "/data/cboe_bc.csv"; /data/webdownloads/getcboe_bc_csv.pl ---> $output_file="/data/cboe_bc.csv"; /data/webdownloads/getcboe_bc_csv.pl ---> system("/data/cboe_bc_checker.pl"); /data/dbscripts/getcboe_bc.pl ---> $bc_file = "/data/cboe_bc.csv"; /data/dbscripts/getcboe_bc.pl ---> $bc_file = "/data/c2_bc.csv"; /data/dbscripts/getcboe_bc.pl ---> $bc_file = "/data/cboe_bc.csv"; /data/dbscripts/getcboe_bc.pl ---> $bc_file = "/data/c2_bc.csv"; /data/webdownloads/cboe_restricted.pl ---> $compliance_dir="/data/compliance"; /data/webdownloads/cboe_restricted.pl ---> $puc_file="/data/restricted.csv"; /data/webdownloads/cboe_restricted.pl ---> $final_file="/data/restricted.csv"; /data/webdownloads/cboe_restricted.pl ---> #$second_file="/data/iserestricted.csv"; /data/checkclosingprices.pl ---> $pxdir="/db/irdb/px"; dead file handle no such file or directory @ ./slurp_autosys_config.justexec2 line 10, <$autosys_fh> line 352.
when check file - file 352 - can't open file. there nothing in it.
- how make program run if there empty file?
- how keep track of empty files?
#!/usr/bin/perl use strict; use warnings; open $autosys_fh, '<', "/data/autosys-us.cfg" or die "can't open file $!"; while (my $cfg_line = <$autosys_fh>) { if ($cfg_line =~ /executable/) { print "$. $cfg_line"; } }
this troubleshoot results - dead file.
walt@host:~/walt $ ./cont-executable | head -22 | tail -2 352 executable = /data/checkclosingprices.v2.pl 365 executable = /data/cboe_quote_rate_check.sh walt@host:~/walt $ walt@host:~/walt $ cat /data/checkclosingprices.v2.pl cat: /data/checkclosingprices.v2.pl: no such file or directory walt@host:~/walt $i
this should work you. fixes error in first regex ( [sh,pl,ksh]
matches single character , same [,hklps]
) , warns , continues if of files can't opened.
use strict; use warnings; open $autosys_fh, '<', '/data/autosys-us.cfg' or die "can't open autosys config file: $!"; while ( <$autosys_fh> ) { next unless /executable/; chomp; $cut = substr $_, 13; next unless $cut =~ m{ / \s* \. (?: sh | pl | ksh ) }x; open $cut_fh, '<', $cut or { warn qq{can't open file "$cut": $!}; next; }; while ( <$cut_fh> ) { next unless m{ "/ \s* " }x; $path = $_; print "$cut ---> $path"; sleep 1; } }
Comments
Post a Comment