On Aug 5, 2:52 pm, [EMAIL PROTECTED] (Hashmat Khan) wrote:
> Hello Rob,
>
> Thanks for the reply.
> Yes, I am using  Net::Telnet. And I am new to perl, I was not aware if there
> are other methods to start telnet using perl.
> I did as you suggested. It worked but not completely as I wanted the output.
>     use Net::Telnet ();
>     $t = new Net::Telnet (Timeout => 10,
>                           Prompt => $prompt,
>                   Dump_Log   => \*STDOUT);
>
> What is this \* used for ? Previoulsy I tried with only STDOUT and it hadn't
> worked.
>
> Basically I am looking for an output that would come as if for example I had
> used windows telnet to login to some server.
> In this output, first I see hex output too. Secondly, I don't see the prompt
> after executing each command. Thirdly, I don't see the output for the
> commands, like I used 'ls'. And I am using:
>  $t->print("ls");  I am not using cmd as it timeout for some of the
> commands.
>
> So I want to print all the input provided in the script and all the output.
>
> Thanks,
> Hashmat
>
> On Tue, Aug 5, 2008 at 4:57 AM, Rob Dixon <[EMAIL PROTECTED]> wrote:
> > Hashmat Khan wrote:
>
> > > Has anybody used Telnet ?
>
> > > I want to know, how can we redirect the output to STDOUT instead of
> > > log file ? (Dump_Log   => "dump.txt")
>
> > It's important to tell us exactly what module you're using. Telnet is a
> > comms
> > protocol but I don't  think you mean that. There is no Perl module called
> > Telnet
> > but there are many with Telnet in the name. I assume you're using
> > Net::Telnet as
> > it has a Dump_Log parameter to the constructor method, but it would have
> > been
> > much better if you'd said so.
>
> > I haven't used the module, but the documentation says that the dump_log
> > method
> > will accept an open file handle as well as a file name so
>
> >  $object->dump_log(\*STDOUT);
>
> > should work. It should also be OK to put it as a parameter to the
> > constructor as in
>
> >  my $object = Net::Telnet->new(Dump_Log => \*STDOUT);
>
> > if you'd rather do it like that. Give it a try and see.
>
> > HTH,
>
> > Rob

Hello All,

I didn't see the above postings so far. I was just checking for
emails.
Anyways, now this is my script:

    $t = new Net::Telnet (Timeout => 10,
                          Prompt => $prompt,
                          Dump_Log   => \*STDOUT)

       $t->open($hostname);
    $t->login($username, $passwd)

 @lines = $t->cmd("whoami");
    $t->print("ls");
    ## Set view
    @lines = $t->print("cleartool setview $view");
 print @lines;

    ## change to $$$ dir
    @lines = $t->print("cd $newdir");
    print @lines;

    ## start build
    [EMAIL PROTECTED] = $t->print($bldcmd);

    @lines = $t->print("ls");
    print @lines;

 I do see the output now, but I see hex characters along with the
output. I want in the output as if I started a telnet from windows
machine using windows telnet.
I don't see the prompt changing and I don't see the output for ls. Any
reasons?

thanks,
Hashmat


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to