CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Perl script does not work after migrating from AIX to Linux

 



wlinliang
New User

Jul 18, 2013, 2:19 PM

Post #1 of 4 (504 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.--------


FishMonger
Veteran / Moderator

Jul 18, 2013, 4:05 PM

Post #2 of 4 (501 views)
Re: [wlinliang] Perl script does not work after migrating from AIX to Linux [In reply to] Can't Post

Your error message is not coming from perl, it's coming from the shell script code.


FishMonger
Veteran / Moderator

Jul 18, 2013, 4:20 PM

Post #3 of 4 (499 views)
Re: [wlinliang] Perl script does not work after migrating from AIX to Linux [In reply to] Can't Post

The first problem I see is at the beginning, starting with the shebang line.

Code
#!/usr/bin/kshexport

You're missing the space between ksh and export.

Are you actually running all of those shell statements as a single line without a space separating some of the statements?


wlinliang
New User

Jul 18, 2013, 4:44 PM

Post #4 of 4 (497 views)
Re: [FishMonger] Perl script does not work after migrating from AIX to Linux [In reply to] Can't Post

that is copy/paste issue to lose space.



after I change

if ($3) { open E, "eval print -n \"$3\" |" or leave "cannot eval";

to



if ($3) { open E, "eval echo -n \"$3\" |" or leave "cannot eval";



it works now. thanks.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives