Re^4: How to pass --MORE--
by oguzhantepe (Novice) on Feb 14, 2015 at 20:01 UTC
|
Hi,
the vendor is Audiocodes,mediant 800 I don't know the other details about the device. We just try to make telnet with perl and get configuration backup to a txt file. it runs show running config command.
thanks. | [reply] |
|
|
The documentation I have found for those devices (here and here) is not very friendly. In any case, they look too sophisticated to lack a setting to disable pagination. What do you get when you run help at the CLI?
Anyway, supposing pagination can not be disabled, I would try the following ways:
1. You may be able to download the configuration file through the web interface. Even if that means doing some web-scraping, getting the file would be a reliable operation.
2. Those devices support the TR-069 management protocol (a SOAP interface). If it is enabled you could also use it to download the configuration file.
3. Maybe, the file is also downloadable using TFTP or SCP.
4. Finally, you can use some module as Expect or Net::Telnet to send the command to the device and then repeatedly wait for the --MORE-- prompt and send CRLFs. Then you will have to remove the prompts from the output, but be careful, because it would be easy to mangle the configuration.
| [reply] [d/l] [select] |
Re^4: How to pass --MORE--
by oguzhantepe (Novice) on Feb 15, 2015 at 19:41 UTC
|
hi salva
thanks for your advices.
here is the outputs of help command on CLI
Mediant 800> help
Use '?' in order to show available commands. 'TAB' can
completion
Use 'list' to see all available commands
Mediant 800>
enable Turn on privileged commands
exit Exit from current mode
help Show available commands
history Show a list of previously run co
list Available command list
nslookup resolve host name
ping Ping packets
pwd Display current configuration mo
quit Disconnect
show Show running system information
Could you please give some examples about the usage of Expect and Net:Telnet to ignore --more--?
I've made some tests like below but it does not make sense
could you please check?
$telnet->print('show running-config');
while( my $line = $telnet->getline() )
{
push @lines, $line;
$match = $telnet->waitfor(Match => '/\-\-More\-\-$/i');
if ($match =~ /\-\-More\-\-/){
$telnet->print(" ");
}
}
| [reply] [d/l] [select] |
|
|
It seems list would give you the full list of commands.
The problem with your code may be the device not sending a CRLF after the --MORE-- prompt, so getline just stalls waiting for one.
Try using the following code instead:
while(1) {
my $match = $telnet->waitfor(Match => '/^--More--$/i',
Match => '/^Mediant 800 >/i',
Mathc => '/.*$/');
last unless defined $match;
if ($match =~ /^--More--/i) {
$telnet->print(' ');
# ignore line
}
elsif ($match =~ /^Mediant 800 >/i) {
# back at command prompt;
last;
}
else {
push @lines, $match;
}
}
| [reply] [d/l] [select] |
Re^4: How to pass --MORE--
by oguzhantepe (Novice) on Feb 16, 2015 at 11:38 UTC
|
Hi Salva, here is the output of list command
Commands available:
clear alarms-history
clear l2tp-server all
clear l2tp-server conn [CONN]
clear pptp-server all
clear pptp-server conn [CONN]
enable
exit
help
history
list
nslookup [STRING]
nslookup [STRING] source voip
nslookup [STRING] source voip interface vlan [1-3999]
nslookup [STRING] source voip interface vlan [1-3999] type A
nslookup [STRING] source voip interface vlan [1-3999] type AAAA
nslookup [STRING] source voip interface vlan [1-3999] type NAPTR
nslookup [STRING] source voip interface vlan [1-3999] type SRV
nslookup [STRING] type A
nslookup [STRING] type A source voip
nslookup [STRING] type A source voip interface vlan [1-3999]
nslookup [STRING] type AAAA
nslookup [STRING] type AAAA source voip
nslookup [STRING] type AAAA source voip interface vlan [1-3999]
--MORE--
nslookup [STRING] source voip interface vlan [1-3999] type SRV
nslookup [STRING] type A
nslookup [STRING] type A source voip
nslookup [STRING] type A source voip interface vlan [1-3999]
nslookup [STRING] type AAAA
nslookup [STRING] type AAAA source voip
nslookup [STRING] type AAAA source voip interface vlan [1-3999]
nslookup [STRING] type NAPTR
nslookup [STRING] type NAPTR source voip
nslookup [STRING] type NAPTR source voip interface vlan [1-3999]
nslookup [STRING] type SRV
nslookup [STRING] type SRV source voip
nslookup [STRING] type SRV source voip interface vlan [1-3999]
ping [A.B.C.D or hostname]
ping [A.B.C.D or hostname] source voip
ping [A.B.C.D or hostname] source voip interface vlan [1-3999]
ping [A.B.C.D or hostname] source voip interface vlan [1-3999] repeat
+ [1-300]
ping [A.B.C.D or hostname] source voip interface vlan [1-3999] repeat
+ [1-300]
ize [500-20000]
ping [A.B.C.D or hostname] source voip interface vlan [1-3999] size [
+500-20000
ping [A.B.C.D or hostname] source voip interface vlan [1-3999] size [
+500-20000
repeat [1-300]
--MORE--
ping [A.B.C.D or hostname] source voip interface vlan [1-3999] size [
+500-20000
repeat [1-300]
ping [A.B.C.D or hostname] source voip repeat [1-300]
ping [A.B.C.D or hostname] source voip repeat [1-300] size [500-20000
+]
ping [A.B.C.D or hostname] source voip size [500-20000]
ping [A.B.C.D or hostname] source voip size [500-20000] repeat [1-300
+]
pwd
quit
show running-config
show running-config full
show system active-alarms
show system alarms-history
show system assembly
show system date
show system feature-key
show system ntp-status
show system time
show system uptime
show system version
show voip dsp perf
show voip dsp status
show voip gw calls-count ip2tel
show voip gw calls-count tel2ip
--MORE--
show voip gw statistics basic
show voip interface e1-t1
show voip interface e1-t1 [X/Y (Slot/Port)]
show voip interface fxs-fxo
show voip interface fxs-fxo [X/Y (Slot/Port)]
show voip interface network
show voip interface network [0-47]
show voip interface network description
show voip ports
show voip register
show voip register accounts
show voip register gw
show voip register ports
show voip register sas
show voip register sbc
show voip register userinfo gw
show voip register userinfo sbc
show voip route
show voip tdm
thanks | [reply] [d/l] |
|
|
The command set looks similiar to Cisco's, where the command for setting the page length (and disabling paging) is a privileged command.
in your command list, there's an enable command. Try to issue this command, which probably will require an additional password, and repeat the list command (or try to issue a terminal pager 0 command.
| [reply] [d/l] [select] |
Re^4: How to pass --MORE--
by oguzhantepe (Novice) on Feb 16, 2015 at 13:27 UTC
|
Hi Salva;
I can get the all the configuration to a txt file thanks, but there is some bad characters in this file like BSBSBS is it backspace? How can I replace it with using perl? I can't do this?
thanks
| [reply] |
|
|
| [reply] |
Re^4: How to pass --MORE--
by oguzhantepe (Novice) on Feb 17, 2015 at 13:15 UTC
|
Hi again salva,
is there any way to remove empty lines from array?
I tried with grep but it doesn't work.
thnaks. | [reply] |
|
|
@lines = grep is_empty($_), @lines;
Where is_empty depends of your definition of empty. For instance:
sub is_empty {
my $line = shift;
$line eq ''
}
BTW, even if you may still be facing the same issue, this is a different question. You should open a new thread for it. | [reply] [d/l] [select] |