
wlinliang
New User
Jul 18, 2013, 2:19 PM
Post #1 of 4
(2222 views)
|
Perl script does not work after migrating from AIX to Linux
|
Can't Post
|
|
hi, after migration perl from aix to Linux, the script does not work. here is the code and error message:#!/usr/bin/kshexport SCRIPT=$(basename $0)export PROJECT_DIR=/usr/local/aml3/opfIN_FILE=/usr/local/aml3/opf/OCIF/cfg/eval_config.cfgcat $IN_FILE | \ perl -ne \ ' sub leave { print STDERR $ENV{SCRIPT}, ": file [", $ENV{IN_FILE}, "]: line [$lineCount]: error: [", $_[0], "]", "\n"; exit 1 } $line = $_; $line =~ s/\n//o; $out = ""; $lineCount++; while ($line =~ m/ (([^\$] | \$[0-9])+) | (( \$ ( ({ [_a-zA-Z][_a-zA-Z0-9]* } ) | ( [_a-zA-Z][_a-zA-Z0-9]* ) ) )+) /xgo) { if ($1) { $out .= $1 } if ($3) { open E, "eval print -n \"$3\" |" or leave "cannot eval"; read E, $e, 4096 or leave "cannot read from eval"; close E; $out .= $e } # the open above fails if eval returns an error # or if eval does not output anything to stdout } printf $out, "\n"; '--------sh: print: command not found test_perl.ksh: file []: line [1]: error: [cannot read from eval] the sample test file: /usr/local/aml3/opf/OCIF/cfg>cat eval_config.cfg ${PROJECT_DIR}/OCIF/cfg/catalog.cfg.templ : ${PROJECT_DIR}/OCIF/cfg/catalog.cfg ${PROJECT_DIR}/OCIF/cfg/all_tables.dat.templ : ${PROJECT_DIR}/OCIF/cfg/all_tables.dat thanks.--------
|