K
Keith
I've been using Net::SSH:
erl to log in to Cisco routers and perform
tasks, but there's one thing I can't seem to do. Without opening an
actual interactive shell, I just want to capture (in a string) the
actual command prompt upon logging in. For example, when you log into
a Cisco router via a telnet or SSH shell, the prompt is normally
something like "Router>".
The reason I need to do this is to tell the level of access; i.e. the
prompt "Router>" tells you that you're in EXEC mode, the prompt
"Router#" tells you that you're in privileged mode, and
"Router(config)#" tells you that you're in configuration mode. This
isn't specific to Cisco either -- logging into another UNIX machine
obviously gives you a specific prompt that reveals the host, user, and
shell.
The method $ssh->cmd() works fine, but it just returns the output
resulting from a specific command. i.e., if you give the command:
my ($stdout, $stderr, $exit_status) = $ssh->cmd('show ip route');
The $stdout string will contain the output from the command (in this
case the routing table), but it won't give the contents of the actual
command prompt. I'd appreciate any advice if anyone has had to do this
before. Thanks!
tasks, but there's one thing I can't seem to do. Without opening an
actual interactive shell, I just want to capture (in a string) the
actual command prompt upon logging in. For example, when you log into
a Cisco router via a telnet or SSH shell, the prompt is normally
something like "Router>".
The reason I need to do this is to tell the level of access; i.e. the
prompt "Router>" tells you that you're in EXEC mode, the prompt
"Router#" tells you that you're in privileged mode, and
"Router(config)#" tells you that you're in configuration mode. This
isn't specific to Cisco either -- logging into another UNIX machine
obviously gives you a specific prompt that reveals the host, user, and
shell.
The method $ssh->cmd() works fine, but it just returns the output
resulting from a specific command. i.e., if you give the command:
my ($stdout, $stderr, $exit_status) = $ssh->cmd('show ip route');
The $stdout string will contain the output from the command (in this
case the routing table), but it won't give the contents of the actual
command prompt. I'd appreciate any advice if anyone has had to do this
before. Thanks!