![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script to automate mksysb via nim in AIX 5.3 | barkath | Shell Programming and Scripting | 0 | 12-20-2007 03:46 PM |
| How to call a perl script from a shell script | anumkoshy | Shell Programming and Scripting | 2 | 08-30-2007 01:23 AM |
| Wget call in a Perl script | rahulrathod | UNIX for Advanced & Expert Users | 1 | 12-28-2005 03:45 AM |
| how to call a perl script from tcsh? | megastar | Shell Programming and Scripting | 1 | 10-22-2005 02:48 PM |
| how can call perl script as command? | umen | UNIX for Dummies Questions & Answers | 1 | 10-14-2005 06:43 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
here document to automate perl script that call script
I am trying to use a here document to automate testing a perl script however when the perl script hits a
Code:
system(perl subscript.pl) here is my script Code:
$ cat test.sh #ksh for testcase do program <<-EOF | tee -a funcscnlog.log y functional 2 $testcase reload keep EOF cd log cp x.log x.$testcase.log cd .. done $ sh test.sh TC01 TC02 TC03 while testing this i also found a odd out put from perl Code:
$ cat test.pl
print "infirst ";
my $buffer = <STDIN>;
chomp($buffer);
print $buffer;
print "me";
system("perl runtest.pl");
print "\naftercall ";
my $buffer = <STDIN>;
print $buffer;
print "\n";
$ cat runtest.pl
print "\ninsubtest ";
my $buffer = <STDIN>;
chomp($buffer);
print $buffer;
$ perl test.pl
infirst a
insubtest b
bame
aftercall c
c
$
Code:
system("perl runtest.pl");
Code:
print $buffer; print "me"; |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
program <<-EOF | tee -a funcscnlog.log y functional 2 $testcase reload keep EOF (b) move all the text from "y" to "EOF" to the far left, at the very least the "EOF" must be in the far left column. |
|
#3
|
|||
|
|||
|
the - in front of EOF tells the here doc to ignore any leading whitespace to allow it to be indented for easy looking code. There is no problem with the here document as I use this syntax on numrous other occassions successfully. The problem only occurs when the perl script "program" calls a subscript
|
|
#4
|
|||
|
|||
|
apparently it is due to the way perl buffer all 1024 bytes of stdin on the first call leaving it not readable for the rest subsequent calls.
I have replaced the system("perl runtest.pl"); with Code:
require "runtest.pl"; |
|||
| Google The UNIX and Linux Forums |