use strict;
use warnings;
my @cmd_list = ( 'db2', 'connect to ctinld01 user db2tf0 using db2tf0'
+, 'describe select * from indic.name');
$|++; # turn off buffering
my $shpid = open( my $sh, '|-', '/bin/bash' )
or die "Can't open a shell process: $!\n";
for my $cmd ( @cmd_list ) {
if($cmd eq "describe select * from indic.name")
{
open (STDOUT, "| tee -ai logs.txt");
print $sh "$cmd\n";
print "It Works!";
close STDOUT;
}
else
{
print $sh "$cmd\n";
}
}
print $sh "exit\n";
close $sh;
waitpid( $shpid, 0 );
print "Shell's all done. Moving right along...\n";