Hi All,

I want to run multiple commands on a remote machine simultaneously. What I
did is created a thread for each command, created an ssh object for each
command and passed it to a function which simply runs command on remote
machine using SSH.

Here is the part of the code

===============================================================
sub commands($) {

....
....
# creating SSH objects and login to all of them
    foreach $count (0 .. scalar(@commands)) {
        push @ssh_objs, SSH->new(%args);
        $ssh_objs[$count]->login($self->get_user(), $self->get_password());
    }

# create threads and pass thread function ssh object and command to be
executed
    $count = 0;
    foreach $_ (@commands) {
        push @thr_ids, Thread->new(\&run_single_command, $ssh_objs[$count],
$_);
        $count++;
    }

# join all the threads.
    $_->join foreach @thr_ids;
}
===============================================================

If I put thread joining loop, the code segment faults. If I do not put the
join loop, every thing works correctly but at last it displays a message
indicating threads are not joined properly.

I am not sure where I am going wrong. PLease suggest

Thanks and Regards,
Prasad

Reply via email to