Re: [Mikrotik] Net::Telnet Mikrotik

2010-07-01 Thread Justin Marshall
As far as the API; that's a little more than what I need, and don't
really have the time to give it too much thought.  DNS isn't the issue
as well.  

Thanks for the reply

-Original Message-
From: mikrotik-boun...@mail.butchevans.com
[mailto:mikrotik-boun...@mail.butchevans.com] On Behalf Of Blake
Covarrubias
Sent: Wednesday, June 30, 2010 3:47 PM
To: Mikrotik discussions
Subject: Re: [Mikrotik] Net::Telnet  Mikrotik

I've seen telnet take a while to respond before login if there are no
DNS resolvers programmed in the unit.

Just curious, but have you thought about using the API?

http://forum.mikrotik.com/viewtopic.php?f=9t=22744

--
Blake Covarrubias

On Jun 30, 2010, at 11:16, Justin Marshall just...@pdmnet.net wrote:

 Hi,
 
 I'm trying to write a simple perl script to automate things on our
 network.  I'm using Net::Telnet and (in this case) i would like it
just
 to disable ports 2-5  re-enable them.  The script does what i would
 like, but i could literally do it manually much quicker.  The other
 devices i've used Net::Telnet on in the past seem to have no issues,
 only on Mikrotik's.  From what i can tell it's taking almost 6-8
seconds
 to logon to each device ... It takes that long before i see it disable
 them...
 
 #!/usr/bin/perl
 use Net::Telnet;
 @Hosts[0] = '10.10.10.2';
 @Hosts[1] = '10.10.10.3';
 @Hosts[2] = '10.10.10.4';
 my $mt = new Net::Telnet;
 my $prompt = /.* /;
 $username = admin;
 $password = ;
 foreach $host(@Hosts) {
   $mt-input_log(log.txt);
   print Opening Host.$host.\n;
   $mt-open(Host=$host);
   $mt-login($username,$password);
   $mt-cmd('/interface disable ether2');
   $mt-cmd('/interface disable ether3');
   $mt-cmd('/interface disable ether4');
   $mt-cmd('/interface disable ether5');
   sleep 1;
   $mt-cmd('/interface enable ether2');
   $mt-cmd('/interface enable ether3');
   $mt-cmd('/interface enable ether4');
   $mt-cmd('/interface enable ether5');
   $mt-close;
   }
 
 I've tried changing out 'cmd' with 'print'.  Tried using 'waitfor',
 'prompt' and even manually logging in with 'waitfor('/password:.*$/i')
 ..etc.  
 
 Is there anything that I may do to speed this up, or am I just missing
 something?
 
 Thanks,
 Justin
 just...@pdmnet.net 
 
 -- next part --
 An HTML attachment was scrubbed...
 URL:
http://www.butchevans.com/pipermail/mikrotik/attachments/20100630/a6a9b
6ce/attachment.html
 ___
 Mikrotik mailing list
 Mikrotik@mail.butchevans.com
 http://www.butchevans.com/mailman/listinfo/mikrotik
 
 Visit http://blog.butchevans.com/ for tutorials related to Mikrotik
RouterOS

___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik
RouterOS
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS


Re: [Mikrotik] Net::Telnet Mikrotik

2010-07-01 Thread Sam Tetherow
The API with perl is significantly easier and more reliable than using 
Net::Telnet or Net::SSH.  If you have problems or questions feel free to 
email I've used it quite a bit as well as writing my own back in the day 
(still expect for the old 2.x installs I still have out).


 Sam Tetherow
 Sandhills Wireless

Justin Marshall wrote:

As far as the API; that's a little more than what I need, and don't
really have the time to give it too much thought.  DNS isn't the issue
as well.  


Thanks for the reply

-Original Message-
From: mikrotik-boun...@mail.butchevans.com
[mailto:mikrotik-boun...@mail.butchevans.com] On Behalf Of Blake
Covarrubias
Sent: Wednesday, June 30, 2010 3:47 PM
To: Mikrotik discussions
Subject: Re: [Mikrotik] Net::Telnet  Mikrotik

I've seen telnet take a while to respond before login if there are no
DNS resolvers programmed in the unit.

Just curious, but have you thought about using the API?

http://forum.mikrotik.com/viewtopic.php?f=9t=22744

--
Blake Covarrubias

On Jun 30, 2010, at 11:16, Justin Marshall just...@pdmnet.net wrote:

  

Hi,

I'm trying to write a simple perl script to automate things on our
network.  I'm using Net::Telnet and (in this case) i would like it


just
  

to disable ports 2-5  re-enable them.  The script does what i would
like, but i could literally do it manually much quicker.  The other
devices i've used Net::Telnet on in the past seem to have no issues,
only on Mikrotik's.  From what i can tell it's taking almost 6-8


seconds
  

to logon to each device ... It takes that long before i see it disable
them...

#!/usr/bin/perl
use Net::Telnet;
@Hosts[0] = '10.10.10.2';
@Hosts[1] = '10.10.10.3';
@Hosts[2] = '10.10.10.4';
my $mt = new Net::Telnet;
my $prompt = /.* /;
$username = admin;
$password = ;
foreach $host(@Hosts) {
  $mt-input_log(log.txt);
  print Opening Host.$host.\n;
  $mt-open(Host=$host);
  $mt-login($username,$password);
  $mt-cmd('/interface disable ether2');
  $mt-cmd('/interface disable ether3');
  $mt-cmd('/interface disable ether4');
  $mt-cmd('/interface disable ether5');
  sleep 1;
  $mt-cmd('/interface enable ether2');
  $mt-cmd('/interface enable ether3');
  $mt-cmd('/interface enable ether4');
  $mt-cmd('/interface enable ether5');
  $mt-close;
  }

I've tried changing out 'cmd' with 'print'.  Tried using 'waitfor',
'prompt' and even manually logging in with 'waitfor('/password:.*$/i')
..etc.  


Is there anything that I may do to speed this up, or am I just missing
something?

Thanks,
Justin
just...@pdmnet.net 


-- next part --
An HTML attachment was scrubbed...
URL:


http://www.butchevans.com/pipermail/mikrotik/attachments/20100630/a6a9b
6ce/attachment.html
  

___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik


RouterOS

___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik
RouterOS
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS
  


___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS


Re: [Mikrotik] Net::Telnet Mikrotik

2010-07-01 Thread Robert Andrews
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thank you!  That made my ssh's totally instantaneous!   Huge difference.

Robert

On 07/01/2010 09:35 AM, John Vogel wrote:
 Depending on the MT version... at some point around 3.2 MT added an
 option to append +ct to the username to suppress ansi output and
 terminal type detection (I think thats what they do).
 
 Try changing the login username to admin+ct
 
 Justin Marshall wrote:
 Hi,

 I'm trying to write a simple perl script to automate things on our
 network.  I'm using Net::Telnet and (in this case) i would like it just
 to disable ports 2-5  re-enable them.  The script does what i would
 like, but i could literally do it manually much quicker.  The other
 devices i've used Net::Telnet on in the past seem to have no issues,
 only on Mikrotik's.  From what i can tell it's taking almost 6-8 seconds
 to logon to each device ... It takes that long before i see it disable
 them...

 #!/usr/bin/perl
 use Net::Telnet;
 @Hosts[0] = '10.10.10.2';
 @Hosts[1] = '10.10.10.3';
 @Hosts[2] = '10.10.10.4';
 my $mt = new Net::Telnet;
 my $prompt = /.* /;
 $username = admin;
 $password = ;
 foreach $host(@Hosts) {
  $mt-input_log(log.txt);
  print Opening Host.$host.\n;
  $mt-open(Host=$host);
  $mt-login($username,$password);
  $mt-cmd('/interface disable ether2');
  $mt-cmd('/interface disable ether3');
  $mt-cmd('/interface disable ether4');
  $mt-cmd('/interface disable ether5');
  sleep 1;
  $mt-cmd('/interface enable ether2');
  $mt-cmd('/interface enable ether3');
  $mt-cmd('/interface enable ether4');
  $mt-cmd('/interface enable ether5');
  $mt-close;
  }

 I've tried changing out 'cmd' with 'print'.  Tried using 'waitfor',
 'prompt' and even manually logging in with 'waitfor('/password:.*$/i')
 ..etc.  

 Is there anything that I may do to speed this up, or am I just missing
 something?

 Thanks,
 Justin
 just...@pdmnet.net 

 -- next part --
 An HTML attachment was scrubbed...
 URL: 
 http://www.butchevans.com/pipermail/mikrotik/attachments/20100630/a6a9b6ce/attachment.html
 ___
 Mikrotik mailing list
 Mikrotik@mail.butchevans.com
 http://www.butchevans.com/mailman/listinfo/mikrotik

 Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS

   
 
 ___
 Mikrotik mailing list
 Mikrotik@mail.butchevans.com
 http://www.butchevans.com/mailman/listinfo/mikrotik
 
 Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS
 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMLMTIAAoJEC+8HUjSuDOsvH8IAID7eSe0bdsh1WrNAysyqOQP
tqWACHeqowBCDWsYHuJnM89rZffFECpSCDGRxjqkYAD8oMwDzCnDzgVdfppKOdfW
ykpmT9hHO04j5x66rlRvnACYbDCvBZxLWnqRzlX2+kee/e3i6TyLRX2jRjEmQzyx
xM0fX9iX3ka2A+fpKAXuqL09n6p/plXE1NlP47/BgYPSjS0J6oOqh+VGVAOkp1qp
S3vlPgNgW0LAiEqg7VQYvmXv9WhhgXuD/yPH03moNB5GHVSTnbqh83WXbgmF/Y2i
iDrRfpAwCyP6LkAjuvZpTjjDhgDH2QwkmuMBHNLYZMvkHG5cPb27/2n2RkZl9cU=
=VtfG
-END PGP SIGNATURE-
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS


Re: [Mikrotik] Net::Telnet Mikrotik

2010-07-01 Thread Rory McCann

+1

That sped up one of my scripts significantly as well. I was using telnet 
via ASP.


On 7/1/2010 11:39 AM, Robert Andrews wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thank you!  That made my ssh's totally instantaneous!   Huge difference.

Robert

On 07/01/2010 09:35 AM, John Vogel wrote:
   

Depending on the MT version... at some point around 3.2 MT added an
option to append +ct to the username to suppress ansi output and
terminal type detection (I think thats what they do).

Try changing the login username to admin+ct

Justin Marshall wrote:
 

Hi,

I'm trying to write a simple perl script to automate things on our
network.  I'm using Net::Telnet and (in this case) i would like it just
to disable ports 2-5  re-enable them.  The script does what i would
like, but i could literally do it manually much quicker.  The other
devices i've used Net::Telnet on in the past seem to have no issues,
only on Mikrotik's.  From what i can tell it's taking almost 6-8 seconds
to logon to each device ... It takes that long before i see it disable
them...

#!/usr/bin/perl
use Net::Telnet;
@Hosts[0] = '10.10.10.2';
@Hosts[1] = '10.10.10.3';
@Hosts[2] = '10.10.10.4';
my $mt = new Net::Telnet;
my $prompt = /.*  /;
$username = admin;
$password = ;
foreach $host(@Hosts) {
$mt-input_log(log.txt);
print Opening Host.$host.\n;
$mt-open(Host=$host);
$mt-login($username,$password);
$mt-cmd('/interface disable ether2');
$mt-cmd('/interface disable ether3');
$mt-cmd('/interface disable ether4');
$mt-cmd('/interface disable ether5');
sleep 1;
$mt-cmd('/interface enable ether2');
$mt-cmd('/interface enable ether3');
$mt-cmd('/interface enable ether4');
$mt-cmd('/interface enable ether5');
$mt-close;
}

I've tried changing out 'cmd' with 'print'.  Tried using 'waitfor',
'prompt' and even manually logging in with 'waitfor('/password:.*$/i')
..etc.

Is there anything that I may do to speed this up, or am I just missing
something?

Thanks,
Justin
just...@pdmnet.net

-- next part --
An HTML attachment was scrubbed...
URL:http://www.butchevans.com/pipermail/mikrotik/attachments/20100630/a6a9b6ce/attachment.html
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS


   

___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS

 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMLMTIAAoJEC+8HUjSuDOsvH8IAID7eSe0bdsh1WrNAysyqOQP
tqWACHeqowBCDWsYHuJnM89rZffFECpSCDGRxjqkYAD8oMwDzCnDzgVdfppKOdfW
ykpmT9hHO04j5x66rlRvnACYbDCvBZxLWnqRzlX2+kee/e3i6TyLRX2jRjEmQzyx
xM0fX9iX3ka2A+fpKAXuqL09n6p/plXE1NlP47/BgYPSjS0J6oOqh+VGVAOkp1qp
S3vlPgNgW0LAiEqg7VQYvmXv9WhhgXuD/yPH03moNB5GHVSTnbqh83WXbgmF/Y2i
iDrRfpAwCyP6LkAjuvZpTjjDhgDH2QwkmuMBHNLYZMvkHG5cPb27/2n2RkZl9cU=
=VtfG
-END PGP SIGNATURE-
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS
   

-- next part --
An HTML attachment was scrubbed...
URL: 
http://www.butchevans.com/pipermail/mikrotik/attachments/20100701/ffa49fad/attachment.html
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS


Re: [Mikrotik] Net::Telnet Mikrotik

2010-07-01 Thread Justin Marshall
Tried it, same ..really slow.  Disabling / Reenabling 16 ports still
takes about 35+ seconds.

Appreciate the reply.

-Original Message-
From: mikrotik-boun...@mail.butchevans.com
[mailto:mikrotik-boun...@mail.butchevans.com] On Behalf Of John Vogel
Sent: Thursday, July 01, 2010 12:36 PM
To: Mikrotik discussions
Subject: Re: [Mikrotik] Net::Telnet  Mikrotik

Depending on the MT version... at some point around 3.2 MT added an
option to append +ct to the username to suppress ansi output and
terminal type detection (I think thats what they do).

Try changing the login username to admin+ct

Justin Marshall wrote:
 Hi,

 I'm trying to write a simple perl script to automate things on our
 network.  I'm using Net::Telnet and (in this case) i would like it
just
 to disable ports 2-5  re-enable them.  The script does what i would
 like, but i could literally do it manually much quicker.  The other
 devices i've used Net::Telnet on in the past seem to have no issues,
 only on Mikrotik's.  From what i can tell it's taking almost 6-8
seconds
 to logon to each device ... It takes that long before i see it disable
 them...

 #!/usr/bin/perl
 use Net::Telnet;
 @Hosts[0] = '10.10.10.2';
 @Hosts[1] = '10.10.10.3';
 @Hosts[2] = '10.10.10.4';
 my $mt = new Net::Telnet;
 my $prompt = /.* /;
 $username = admin;
 $password = ;
 foreach $host(@Hosts) {
   $mt-input_log(log.txt);
   print Opening Host.$host.\n;
   $mt-open(Host=$host);
   $mt-login($username,$password);
   $mt-cmd('/interface disable ether2');
   $mt-cmd('/interface disable ether3');
   $mt-cmd('/interface disable ether4');
   $mt-cmd('/interface disable ether5');
   sleep 1;
   $mt-cmd('/interface enable ether2');
   $mt-cmd('/interface enable ether3');
   $mt-cmd('/interface enable ether4');
   $mt-cmd('/interface enable ether5');
   $mt-close;
   }

 I've tried changing out 'cmd' with 'print'.  Tried using 'waitfor',
 'prompt' and even manually logging in with 'waitfor('/password:.*$/i')
 ..etc.  

 Is there anything that I may do to speed this up, or am I just missing
 something?

 Thanks,
 Justin
 just...@pdmnet.net 

 -- next part --
 An HTML attachment was scrubbed...
 URL:
http://www.butchevans.com/pipermail/mikrotik/attachments/20100630/a6a9b
6ce/attachment.html
 ___
 Mikrotik mailing list
 Mikrotik@mail.butchevans.com
 http://www.butchevans.com/mailman/listinfo/mikrotik

 Visit http://blog.butchevans.com/ for tutorials related to Mikrotik
RouterOS

   

___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik
RouterOS
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS


Re: [Mikrotik] Net::Telnet Mikrotik

2010-06-30 Thread Scott Reed

I use an expect script that does the telnet.  It is reasonably fast.
Justin Marshall wrote:

Hi,

I'm trying to write a simple perl script to automate things on our
network.  I'm using Net::Telnet and (in this case) i would like it just
to disable ports 2-5  re-enable them.  The script does what i would
like, but i could literally do it manually much quicker.  The other
devices i've used Net::Telnet on in the past seem to have no issues,
only on Mikrotik's.  From what i can tell it's taking almost 6-8 seconds
to logon to each device ... It takes that long before i see it disable
them...

#!/usr/bin/perl
use Net::Telnet;
@Hosts[0] = '10.10.10.2';
@Hosts[1] = '10.10.10.3';
@Hosts[2] = '10.10.10.4';
my $mt = new Net::Telnet;
my $prompt = /.* /;
$username = admin;
$password = ;
foreach $host(@Hosts) {
$mt-input_log(log.txt);
print Opening Host.$host.\n;
$mt-open(Host=$host);
$mt-login($username,$password);
$mt-cmd('/interface disable ether2');
$mt-cmd('/interface disable ether3');
$mt-cmd('/interface disable ether4');
$mt-cmd('/interface disable ether5');
sleep 1;
$mt-cmd('/interface enable ether2');
$mt-cmd('/interface enable ether3');
$mt-cmd('/interface enable ether4');
$mt-cmd('/interface enable ether5');
$mt-close;
}

I've tried changing out 'cmd' with 'print'.  Tried using 'waitfor',
'prompt' and even manually logging in with 'waitfor('/password:.*$/i')
..etc.  


Is there anything that I may do to speed this up, or am I just missing
something?

Thanks,
Justin
just...@pdmnet.net 


-- next part --
An HTML attachment was scrubbed...
URL: 
http://www.butchevans.com/pipermail/mikrotik/attachments/20100630/a6a9b6ce/attachment.html
___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS

  


--
Scott Reed
Owner
NewWays Networking, LLC
Wireless Networking
Network Design, Installation and Administration
Mikrotik Advanced Certified
www.nwwnet.net
(765) 855-1060


___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS


Re: [Mikrotik] Net::Telnet Mikrotik

2010-06-30 Thread Blake Covarrubias
I've seen telnet take a while to respond before login if there are no DNS 
resolvers programmed in the unit.

Just curious, but have you thought about using the API?

http://forum.mikrotik.com/viewtopic.php?f=9t=22744

--
Blake Covarrubias

On Jun 30, 2010, at 11:16, Justin Marshall just...@pdmnet.net wrote:

 Hi,
 
 I'm trying to write a simple perl script to automate things on our
 network.  I'm using Net::Telnet and (in this case) i would like it just
 to disable ports 2-5  re-enable them.  The script does what i would
 like, but i could literally do it manually much quicker.  The other
 devices i've used Net::Telnet on in the past seem to have no issues,
 only on Mikrotik's.  From what i can tell it's taking almost 6-8 seconds
 to logon to each device ... It takes that long before i see it disable
 them...
 
 #!/usr/bin/perl
 use Net::Telnet;
 @Hosts[0] = '10.10.10.2';
 @Hosts[1] = '10.10.10.3';
 @Hosts[2] = '10.10.10.4';
 my $mt = new Net::Telnet;
 my $prompt = /.* /;
 $username = admin;
 $password = ;
 foreach $host(@Hosts) {
   $mt-input_log(log.txt);
   print Opening Host.$host.\n;
   $mt-open(Host=$host);
   $mt-login($username,$password);
   $mt-cmd('/interface disable ether2');
   $mt-cmd('/interface disable ether3');
   $mt-cmd('/interface disable ether4');
   $mt-cmd('/interface disable ether5');
   sleep 1;
   $mt-cmd('/interface enable ether2');
   $mt-cmd('/interface enable ether3');
   $mt-cmd('/interface enable ether4');
   $mt-cmd('/interface enable ether5');
   $mt-close;
   }
 
 I've tried changing out 'cmd' with 'print'.  Tried using 'waitfor',
 'prompt' and even manually logging in with 'waitfor('/password:.*$/i')
 ..etc.  
 
 Is there anything that I may do to speed this up, or am I just missing
 something?
 
 Thanks,
 Justin
 just...@pdmnet.net 
 
 -- next part --
 An HTML attachment was scrubbed...
 URL: 
 http://www.butchevans.com/pipermail/mikrotik/attachments/20100630/a6a9b6ce/attachment.html
 ___
 Mikrotik mailing list
 Mikrotik@mail.butchevans.com
 http://www.butchevans.com/mailman/listinfo/mikrotik
 
 Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS

___
Mikrotik mailing list
Mikrotik@mail.butchevans.com
http://www.butchevans.com/mailman/listinfo/mikrotik

Visit http://blog.butchevans.com/ for tutorials related to Mikrotik RouterOS