#### Main Program ### $count = 0; our $sshFD = Expect->spawn("ssh $User\@$mtHostName"); $sshFD->log_stdout(0); our $sshCI = Expect->spawn("ssh $User\@$dbHost1"); $sshCI->log_stdout(0); while (($deltaFound eq "true") && ($count < 2)) { print "******** LOOP ".$count." *******\n"; our $thrFD = threads->create('findDelta',$sshFD); our $thrCI = threads->create('checkInv',$sshCI); $thrFD->join(); $thrCI1->join(); $sshFD->close(); $sshCI1->close(); } sub checkInv() { our $compInvFlag = ''; our $fndDeltaFlag:shared; my $sshAuth = shift; #### this passes the first time... but just keeps printing dots in the second iteration ###### while ($fndDeltaFlag ne "true") { sleep(1); print "."; } #### Crunch some numbers here ##### $sshAuth->close(); } sub findDelta() { our $deltaFound; our $fndDeltaFlag = ''; my $counter = 0; my $sshAuth = shift; ##### Do some stuff here ####### $counter = 0; $deltaFound = "false"; while ($counter <2 ) { $deltaFound = "true"; $counter++; } $fndDeltaFlag = "true"; $sshAuth->close(); }