#!/usr/bin/perl -w use threads; ######### Main Starts here ######### for($i=0;$i<10;$i++) { $th.=$i; $th = threads->new(\&sub2,$i); } for($i=0;$i<10;$i++) { $th.=$i; $result = $th->join; $result = $th->eval; $th->detach; } ##### Subroutine 2 defined for thread creation ##### sub sub2 :locked { my @para = @_; my $t = $_[0]; my $temp="test"; my $user=$temp.$t; if (!defined($pid = fork)) { die "Cannot fork\n"; } elsif ($pid == 0 ) { exec("./sshex $user"); } else { waitpid($pid,0); } } #!/usr/bin/expect set ip "164.99.152.91" set user [ lindex $argv 0 ] set at "@" set pass "novell" set mac "$user$at" set path /home/$user/$user set sec [clock seconds] set realm "testRealm" set timeout 20 #spawn "/bin/sh" set file [ open $path w+ ] spawn ssh $user$at$ip sleep 1 puts $file "$sec" expect { "$user$at$ip's password:" { send "$pass\r" expect "$mac" { send "kinit $user$at$realm\r" expect "$user$at$realm's Password:" send "novell\r" sleep 1 expect "$mac" send "ldapsearch -Y GSSAPI -h 164.99.155.248 -b \"\" -s base\r" sleep 5 expect "$mac" } } "Permission denied" { puts :Error in password" } } set sec1 [clock seconds] puts $file "$sec1"