title: Trouble using Telnet in perl?
body: <p>I'm having some trouble send commands and receiving text/data from the telnet connection that I set up. </p>
  
  <pre><code> #!perl
   #Telnet.pl
  
  use Net::Telnet;
  
  # Create a new instance of Net::Telnet, 
  my $telnetCon = new Net::Telnet (Timeout =&gt; 20,
                                  Dump_Log   =&gt; "dump.log",
                                  Input_Log =&gt; "infile.log",
                                  Output_log =&gt; "output.log",
                                  Prompt =&gt; '/\$ $/') or die "Could not make connection.";
  
  # Connect to the host of the users choice                                
  $telnetCon-&gt;open('');
  
  #get username and password from user
  my $CXusername = '';
  my $CXpassword = '';
  
  my $task = '50104'; # Get this input from the search
  
  # Recreate the login
  # Wait for the login: message and then enter the username
  $telnetCon-&gt;waitfor(match =&gt; '/login:/i');
  
  # this method adds a \n to the end of the username, it mimics hitting the enter key after entering your username
  $telnetCon-&gt;print($CXusername);
  
  $telnetCon-&gt;waitfor(match =&gt; '/Password:/i');
  
  # does the same as the previous command but for the password
  $telnetCon-&gt;print($CXpassword);
  
  #Wait for the login successful message
  $telnetCon-&gt;waitfor(match =&gt; '/$/');
  
  $telnetCon-&gt;cmd("viewtask 50104");
  $telnetCon-&gt;cmd(" ");
  $telnetCon-&gt;cmd(" ");
  
  @output = $telnetCon-&gt;cmd("who");
  print @output;
  
  ($output) = $telnetCon-&gt;waitfor(match =&gt; '/$/');
  
  print "Output: ",$output;
  
  if($searched =~ /MODIFIED files in Task $_[1] :(.*?)The/s){
      # to Logout of the telnet connection
      $telnetCon-&gt;print("exit");
  
      #return the modified data 
      return $1;
  }
  </code></pre>
  
  <p>Tell me if the question doesn't make sense, I'll try and reword it.
  <img src="https://i.imgur.com/inM4W.png" alt="First View">
  <img src="https://i.imgur.com/uDDnY.png" alt="Second View"></p>
  
  <p>So this is the telnet view. I get stuck on the first image when i enter the $telnetCon->cmd("viewtask 50140"). I want to get to the second image and continue entering commands into my telnet session.</p>