
diesel_den
Novice
Jun 7, 2009, 8:53 AM
Post #5 of 19
(8325 views)
|
Re: [FishMonger] Problem with Aruba device using plink through IPC::Run
[In reply to]
|
Can't Post
|
|
I have created an example that works in the same way and have the same problem even using telnet.
use IPC::Run qw( start pump finish timeout ); my $username = '<username, 7 characters>'; my $password = '<password, 6 characters>'; my $epassword = '<enable_password, 6 characters>'; my $vars = {}; $vars->{handle} = undef; $vars->{in} = undef; $vars->{out} = undef; $vars->{err} = undef; my @cmd = (); push( @cmd, 'plink' ); push( @cmd, '-v', '-a', '-x' ); # Verbose output, disable agent forwarding, and disable X11 forwarding push( @cmd, '-telnet' ); push( @cmd, '-l', $username ); #push( @cmd, ( '-pw', $password ) ) if $password; #push( @cmd, '-' . $this->{version} ) if $this->{version} =~ /^[12]$/; #push( @cmd, '-C' ) if $this->{compression}; #push( @cmd, ( '-P', $this->{port} ) ); push( @cmd, '<ip_of_device>' ); print "Connecting to the device...\n"; $vars->{handle} = start \@cmd, \$vars->{in}, \$vars->{out}, \$vars->{err}, timeout(100); print "Connected\n"; my_wait_for('User:\s', $vars); my_send($username, $vars); my_wait_for('Password:\s', $vars); my_send($password, $vars); my_wait_for('\(Aruba\)\s>', $vars); my_send('enable', $vars); my_wait_for(':', $vars); my_send($epassword, $vars); my_wait_for('\(Aruba\)\s#', $vars); my_send('config term', $vars); my_wait_for('\(Aruba\)\s\(config\)\s#', $vars); my_send('enable', $vars); my_wait_for('Password:', $vars); my_send($epassword, $vars); my_wait_for('password:', $vars); my_send($epassword, $vars); my_wait_for('#', $vars); my_send('exit', $vars); my_wait_for('#', $vars); sub my_wait_for { my $regex = shift; my $vars = shift; print "\n>>my_wait_for: $regex\n"; until ( $vars->{out} =~ /$regex$/ ) { $vars->{handle}->pump(); print "\n out: $vars->{out}\n"; } } sub my_send { my $input = shift; my $vars = shift; print "\n>>my_send: $input\n"; $vars->{in} .= $input . "\n"; while ( $this->{in} ) { print "\n in: $in"; $vars->{handle}->pump(); print "\n out: $vars->{out}\n"; } } Output of the program:
Connecting to the device... Connected >>my_wait_for: User:\s out: out: out: (Aruba) User: >>my_send: xxxxxxx >>my_wait_for: Password:\s out: (Aruba) User: out: (Aruba) User: x out: (Aruba) User: xxxxxxx Password: >>my_send: yyyyyy >>my_wait_for: \(Aruba\)\s> out: (Aruba) User: xxxxxxx Password: out: (Aruba) User: xxxxxxx Password: ****** (Aruba) > >>my_send: enable >>my_wait_for: : out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >e out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password: >>my_send: zzzzzz >>my_wait_for: \(Aruba\)\s# out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:* out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:****** (Aruba) # >>my_send: config term >>my_wait_for: \(Aruba\)\s\(config\)\s# out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:****** (Aruba) #c out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:****** (Aruba) #configure term Enter Configuration commands, one per line. End with CNTL/Z (Aruba) (config) # >>my_send: enable >>my_wait_for: Password: out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:****** (Aruba) #configure term Enter Configuration commands, one per line. End with CNTL/Z (Aruba) (config) #e out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:****** (Aruba) #configure term Enter Configuration commands, one per line. End with CNTL/Z (Aruba) (config) #enable Password: >>my_send: zzzzzz >>my_wait_for: password: out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:****** (Aruba) #configure term Enter Configuration commands, one per line. End with CNTL/Z (Aruba) (config) #enable Password:* out: (Aruba) User: xxxxxxx Password: ****** (Aruba) >enable Password:****** (Aruba) #configure term Enter Configuration commands, one per line. End with CNTL/Z (Aruba) (config) #enable Password:******* As you see, we have response "*******" instead of "****** Re-Type password:".
(This post was edited by diesel_den on Jun 7, 2009, 11:59 AM)
|