Hi Monks,

I have been working on this for 2 days trying to capture data from a Win2k machine using Net::Telnet. However, I am only getting '1' or empty in the @df array (I printed the contents of the array @df to a text file). I googled many sites with different keywords and could not really find anything that resembles my problem.

Also, the input_log() gave me a bunch 'empty square boxes' separating each line, and they look like they are supposed to have carriage returns (I copied the input_log contents and pasted it in MS Word and saw the empty boxes).

I'm using VT100 emulation in my telnet client(Win XP). I have disabled NTLM authentication in the telnet server(Win2k Advanced Server). The script connects successfully and executes cmd successfully (I did a mkdir and the directory got created, checked dump_log and see the commands executed and also checked input_log). However, I'm not getting any outputs by using @df=$telnet->cmd... I'm trying to capture the output into an array to be used later.

Please help.

Thanks in advance!
auyong

Below is part of the code.
my $write_file=">"; my $initial_data = 'file.txt'; my $dumpfile='storage_dumpfile.txt'; my $inputfile='inputfile.txt'; my $storage_file=$write_file.$directory.'storage_final_file.txt'; open(STORAGE_FILEHANDLE, $storage_file)||die ("Cannot open file please + check if file exists"); $storage_telnet = Net::Telnet->new ( Timeout=>10, Prompt=>'/>/', Dump_Log=>$dumpfile, Input_log=>$inputfile ) or die("Cannot establish connection"); $storage_telnet->login($_[2], $_[3])||die("Cannot login, pleas +e check password\n", dump_log=>$dumpfile); $storage_telnet->cmd ("cd\\Program Files\\Hi\\DManager\\HiCLI\\")|| di +e (dump_log=>$dumpfile); @df=$storage_telnet->cmd(String=>"dir", Prompt=>'/C:\\\\Program Files\ +\\\Hi\\\\DManager\\\\HiCLI*/i')||die(dump_log=>$dumpfile); ##mkdir works, the new directory whatthehell was created ##this was just used to test whether I am in the correct ##directory #@df=$storage_telnet->cmd(String=>"mkdir whatthehell", Prompt=>'/C:\\\ +\Program Files\\\\Hi\\\\DManager\\\\HiCLI*/i')||die(dump_log=>$dumpfi +le); #here $write_file = ">" open (INITIAL_RAW_DATA_FILEHANDLE, $write_file.$initial_data); foreach $element(@df) { print INITIAL_RAW_DATA_FILEHANDLE "$element\n"; } close(INITIAL_RAW_DATA_FILEHANDLE);
Animator, thanks for your input and advise. The reason I had the $write_file is because I have additional logic to decide whether I want to write or append but I guess I could have incorporated the three-param version into my logic instead of having the scalar $write_file.

Latest UPDATE: I have tried waitfor yesterday but still unable to grab the data. I'm not sure if readline can be used with telnet, because it belongs to another package.

Additionally, I have found that the Windows telnet server that I am connecting to does not support streaming data, it is using 'console' mode only. Could this be why I am having problems reading the output? The 5.1 version of windows telnet server supports streaming but I have to install SFU (Support for Unix) on the Windows 2000 Advanced Server machine.

If I can't find a solution to this telnet problem, I will probably have to save the output to a file and ftp to get the file, which presents another dilemma; I have to install IIS with ftp feature on the Windows 2000 Advanced Server machine! So, I'm really hoping that one of you monks out there who knows the telnet module can at least pinpoint the cause of problem that I'm having.

auyong

In reply to Capturing Telnet Command Outputs on Windows 2000 machines by auyong

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.