The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
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 06:46 PM
How to call a perl script from a shell script anumkoshy Shell Programming and Scripting 2 08-30-2007 04:23 AM
Wget call in a Perl script rahulrathod UNIX for Advanced & Expert Users 1 12-28-2005 06:45 AM
how to call a perl script from tcsh? megastar Shell Programming and Scripting 1 10-22-2005 05:48 PM
how can call perl script as command? umen UNIX for Dummies Questions & Answers 1 10-14-2005 09:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-18-2007
hogger84 hogger84 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 3
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)
call, input is no longer entered into this subscript.

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
I don't really want to use expect as I don't want to install anything else on the test system.


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

$
if you look closly you will see
Code:
system("perl runtest.pl");
is run before

Code:
print $buffer;
print "me";
  #2 (permalink)  
Old 10-18-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Code:
	program <<-EOF | tee -a funcscnlog.log 
	y
	functional
	2
	$testcase
	reload
	keep
	EOF
(a) what is the "-" in front of EOF for?

(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 (permalink)  
Old 10-18-2007
hogger84 hogger84 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 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 (permalink)  
Old 10-22-2007
hogger84 hogger84 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 3
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";
and all works
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0