Hello gentlemen, Beginner to Perl, to scripts, to Linux... the whole package I guess. I got myself interested in scripts because I use a lot of repeated command lines on my server ( NETAPP server ) that I manually type everytime... I enjoyed Perl syntax and ... here I am. Using Perl on Ubuntu and tried to do something like a little program to let me use my commands simply and quickly by just using shortcuts with my keypad numbers I can send simple command lines to my server without any troubles... Problem comes when I need to respond to my server, for example : destroying a "volume" or an "aggregate", my server asks me if I'm sure of this decision with a simple "yes or no", I'm having troubles to "respond". Apologies in advance if I'm not clear enough or if I use wrong/bad terms... I'll try to do my best. So here is an extract of my script :
#!/usr/bin/env perl -w -s use Net::Telnet (); my $username = 'root'; my $password = 'passw0rd'; my $local = '10.10.4.46'; print "46 leads to => 10.10.4.46"; my $machine =<>; chomp $machine; while ($machine ne '46'){ print "\nBad entry :\n"; $machine = <>; chomp $machine; } if ($machine eq '46') { my $t = new Net::Telnet (Timeout => 10); $t->open("$local"); $t->login($username, $password); print "\n\n\n\n\t\t\tConnexion to 10.10.4.46... \n\n\n"; print "Enter to continue\n\n"; my $pass = <>; chomp $pass; while ($pass ne '99') print "004 = destroy volume\n"; my $pass = <>; chomp $pass; if($pass eq '004'){ print "\n\n\n Menu to destroy aggr or a volume\n"; my $value = <>; chomp $value; while($value ne '99'){ print "\n\n Destroy aggr = 1 \t Destroy volume += 2\n\n"; my $choice = <>; chomp $choice; if($choice eq '1'){ @lines =$t ->cmd ("sysconfig -r" +); print @lines; print "\n\nEnter the name of agg +r to destroy"; my $aggr = <>; chomp $aggr; @lines = $t ->print ("aggr destr +oy $aggr"); $t ->waitfor('/Are you sure you +want to destroy this aggregate ?/'); @lines = $t ->cmd ('yes'); print @lines; }

Here's the issue with an aggregate, it actually works, it destroys the aggregate ( checked in with my server ) but I got a timeout ( command timed-out at project.pl line 916 ) at the end of this and my "print @lines;" isn't functionning, don't have any response when I type my aggregate name

elsif($choice eq'2'){ @lines =$t ->cmd ("sysconfig -r" +); print @lines; print "\n\nEnter name of the vol +ume to destroy : "; my $vol = <>; chomp $vol; @lines =$t ->print ("vol destroy + $vol"); $t ->waitfor('/Are you sure you +want to destroy this volume ?/'); $t ->cmd ('yes'); print @lines; }

The exact same thing in here, it destroys my volume but also got a timeout and no response/display....

print "\n\n\n Entrer pour conti +nuer... (99 pour quitter)\n"; my $exit = <>; chomp $exit; if($exit == "99"){ last; } } }
I hope i've been clear enough for you to understand my situation. Thanks !

In reply to Troubles with Telnet module by Pohkaymon

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.