I have the following script which works fine on all of my servers except for one.The problem is that for this particular server, it is not waiting for the previous command to finish before it sends the next command. I have assured myself that the prompt variable is unique, any help would be appreciated.
sub run_command {
my ($in_prompt,$in_command)=@_;
print $rlogin "$in_command\r";
$rlogin->expect(300,'-re',$in_prompt);
}#end run_command
sub rlogin {
my ($in_hostname,$in_password,$in_prompt,$in_type)=@_;
$rlogin=Expect->spawn($in_type." ".$in_hostname);
$rlogin->expect(300,"ssword:") || die "Never got password prom
+pt on $host, ".$rlogin->exp_error()."\n";
print $rlogin "$in_password\r";
$match=$rlogin->expect(300,"closed by foreign host","-re",$in_
+prompt);
#Used for debugging I think
#die "Dumped by server\n" if $match == 1;
#die "Never got shell prompt on $host, ".$rlogin->exp_error().
+"\n" unless $match;
}#end rlogin
rlogin($hostname,$password,$prompt,"ssh");
run_command($prompt,"export ORACLE_SID=$oracle_sid");
run_command($prompt,"cd dev");
run_command($prompt,"chmod +x *");
run_command($prompt,"exp $schema/$schema file=$file log=$log rows=no")
+;
run_command($prompt,"imp $schema/$schema file=$file indexfile=$indexfi
+le full=y");
run_command($prompt,"./initial.pl ".$schema."_tabind LOC_".$touser."
+$touser $schema ");
Edit 2001-26-06 Masem - Added code tags