Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Multithreading Ssh使用expect和线程?_Multithreading_Perl_Ssh_Expect.pm - Fatal编程技术网

Multithreading Ssh使用expect和线程?

Multithreading Ssh使用expect和线程?,multithreading,perl,ssh,expect.pm,Multithreading,Perl,Ssh,Expect.pm,您找到了如何使用expect with threads进行ssh的解决方案吗 sub thDoWork { #variables my $thread_number = $_[0]; my $PassStoreQueue = $_[1]; my $Thread_Die = ''; my $My_Print_Bucket = ''; while ($Thread_Die ne 'KILL_THREAD') { my $tem

您找到了如何使用expect with threads进行ssh的解决方案吗

sub thDoWork {

    #variables

    my $thread_number = $_[0];
    my $PassStoreQueue = $_[1];

    my $Thread_Die = '';
    my $My_Print_Bucket = '';

    while ($Thread_Die ne 'KILL_THREAD') {

        my $temp_Store_Number_Working_On = $PassStoreQueue->dequeue();

        my $name;
        my $ip;
        my $Device_Exist;
        my $TempDeviceName;
        my $DNS_Results;

        # I need to ssh inside many threads, I can ssh from the main
        # thread just fine but not a sub thread. 

        $ssh = Expect->spawn("ssh -l $username1 $temp_ssh_device " .
                             "-o UserKnownHostsFile=/dev/null " .
                             "-o StrictHostKeyChecking=no")
            or return "Couldn't spawn ssh session";

        # this is unable to login to device.
}

我读到一个线程,该线程expect在线程中不能正常工作,这仍然是真的吗?

事先创建一个
expect
对象,并将其传递给线程。看见这可能是重复的。可能是重复的。请事先创建
expect
对象并将其传递给线程。看见这可能是一个副本。的可能副本