I need to create a perl script that logs into a switch thru a terminal server, and then sends a control B to enter a command, the a control C to send the command.
All lower case characters are what I need to enter before and after the commands.
what is in red is the actual prompts
what is in yellow is what I need to do to send command
#########
telnet switch1 2008
Trying...
Connected to switch1
Escape character is '^]'.
Cntr b
I@11:25:56 LOG ON cntr c
Cntrl b
ENTER LOGON ID: ID1 ctrl c
ENTER PASSWORD: XXXX ctrl c
R@11:26:19 SIOO008 JOB 0071 09/15/05 SWITCHDS1
ID1 LOGGED ON TERMINAL 20 AT 11:26:19 ON 09/15/05
Ctrl b
I@11:26:57 LOG OFF ctrl c
OK JOB 0072 ASSIGNED
R@11:27:04 SIOO009 JOB 0072 09/15/05 SWITCHDS1
ID1 LOGGED OFF TERMINAL 20 AT 11:27:03 ON 09/15/05
telnet> QUIT
#######
my script
#!/usr/bin/perl -w
use Net::Telnet;
$t = new Net::Telnet (timeout => 10,
Errmode => 'die',
Host => 'switch1',
Port => '2008');
$t->open ();
$t->waitfor('/^Escape character is/');
$t->print ('\cB'); #did try with the actual ^B as well
$t->waitfor('/^I@[0-9]{2}:[0-9]{2}:[0-9]{2}/');
$t->print ('LOG ON^C');
$t->waitfor('/ENTER LOGON ID: /');
$t->print ('ID1^C');
$t->waitfor('/ENTER PASSWORD: /');
$t->print ('XXXX^C');
I can not get this far...
If I can figure out the correct syntax for login then I can enter the rest for the other commands.
All lower case characters are what I need to enter before and after the commands.
what is in red is the actual prompts
what is in yellow is what I need to do to send command
#########
telnet switch1 2008
Trying...
Connected to switch1
Escape character is '^]'.
Cntr b
I@11:25:56 LOG ON cntr c
Cntrl b
ENTER LOGON ID: ID1 ctrl c
ENTER PASSWORD: XXXX ctrl c
R@11:26:19 SIOO008 JOB 0071 09/15/05 SWITCHDS1
ID1 LOGGED ON TERMINAL 20 AT 11:26:19 ON 09/15/05
Ctrl b
I@11:26:57 LOG OFF ctrl c
OK JOB 0072 ASSIGNED
R@11:27:04 SIOO009 JOB 0072 09/15/05 SWITCHDS1
ID1 LOGGED OFF TERMINAL 20 AT 11:27:03 ON 09/15/05
telnet> QUIT
#######
my script
#!/usr/bin/perl -w
use Net::Telnet;
$t = new Net::Telnet (timeout => 10,
Errmode => 'die',
Host => 'switch1',
Port => '2008');
$t->open ();
$t->waitfor('/^Escape character is/');
$t->print ('\cB'); #did try with the actual ^B as well
$t->waitfor('/^I@[0-9]{2}:[0-9]{2}:[0-9]{2}/');
$t->print ('LOG ON^C');
$t->waitfor('/ENTER LOGON ID: /');
$t->print ('ID1^C');
$t->waitfor('/ENTER PASSWORD: /');
$t->print ('XXXX^C');
I can not get this far...
If I can figure out the correct syntax for login then I can enter the rest for the other commands.