rahul.pwav has asked for the wisdom of the Perl Monks concerning the following question:

Here i have written the perl script to run iperf server and client on two different linux box from remote system. Now problem i am getting is that, when i am launching iperf server command then control is not returning back to the remote machine, so that i am unable to run the iperf client. Here is the script::
use Net::SSH::Expect; use Proc::Background; sub process { } sub OpenSshChnl { $hst = shift; $pass = shift; $UN = shift; my $ssh = Net::SSH::Expect->new ( host => $hst, user => $UN, password=> $pass, raw_pty => 1, ); my $login_output = $ssh->login(); if ($login_output !~ /Last login:/){ die "Login has failed. Login output was $login_output" +; } else { print "success \n" } print "Opned ssh channel to $hst\n"; } @sys = (UE,'10.131.24.106',mguvvala,abc123,12345,eNb,'10.131.24.110',m +guvvala,abc123,12345); $ssh_UE1 = OpenSshChnl(@sys[1],@sys[3],@sys[2]); $ssh_eNb1 = OpenSshChnl(@sys[6],@sys[8],@sys[7]); $ssh_eNb1=>exec('iperf -s -u -i 1 -p 12345'); my $client = $ssh_UE1=>exec("iperf -c 10.131.24.110 -u -b 10M -i 1 -t +3 -p 12345"); print "$client";

Replies are listed 'Best First'.
Re: Plz some one help:: question related to iperf and ssh
by Illuminatus (Curate) on Mar 25, 2011 at 19:49 UTC
    You do realize that the 'exec' method executes the command, and waits for it to complete, and return the results? Since the server-side of iperf won't complete until either the client-side is run, or the server-side is run in daemon-mode (ie, with the -D), your first command will hang indefinitely. Your best bet would probably to either:
    1. run the command as you have it, but redirect the output to a file and run it in background (ie, use &)
    2. run the server side with the -D, and use the --output to redirect the output
    Of course, this means that after the client-side finishes, you will have to either retrieve the server-side output file (if you care about it), or use 'exec' again to just 'cat' the output

    fnord