Thanks for the responses guys. Yes just adding this did the trick I can see the output appended to the bottom..
$data .= $self->cmd('some other command', undef, $output_ref);
Having one problem though. If the command is not in format 'show this' I get an error. Thought it was the pipes at first but same issue when creating an alias on the remote device to run the command for me.
Essentially the command is run, grepping string and then displays the last 3 lines of the output.
$data .= $self->cmd('command | grep string | last 3', undef, $output_r +ef);
Here it is again after setting alias name of 'runthis' against 'command | grep string | last 3' on the remote device (works ok locally)
$data .= $self->cmd('runthis', undef, $output_ref);
Error is Use of uninitialized value in concatenation (.) or string... Insecure dependency in sprintf while running with -T switch at ....
Presumably the sub(s) above this command needs amending...
sub smart_cmd { my($self,$cmd,@args) = @_; return $self->show_mem if ($cmd =~ /^\s*show mem/); return $self->show_cfg if ($cmd =~ /^\s*show (conf|run)/); return $self->show_start if ($cmd =~ /^\s*show start/); return $self->set_pass($1,$2) if ($cmd =~ /^\s*set pass\S*\s+(\S+)\s ++(\S+)/); return $self->set_enablepass($1,$2) if ($cmd =~ /^\s*set enablepass\ +S*\s+(\S+)\s+(\S+)/); my($data,$match,$remainder) = $self->cmd($cmd,@args); return (wantarray)?($data,$match,$remainder):$data; } =head2 cmd(); $data = $host->cmd($cmd); ($data,$matched_prompt) = $host->cmd($cmd,$prompt);
Thanks again :)
In reply to Re: Get outputs from 2 commands and add to var
by Cisco_Dave
in thread Get outputs from 2 commands and add to var
by Cisco_Dave
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |