- 论坛徽章:
- 0
|
本帖最后由 iamlimeng 于 2013-09-28 13:46 编辑
- #!/usr/bin/perl
- use strict;
- use XML::Simple qw(XMLin);
- my $device_num = $ARGV[0];
- my @lines = <DATA>;
- my $text = join '', @lines;
- my $xml_data = XMLin($text);
- my $device_list = $xml_data->{device};
- my $device_times = ref ($device_list) eq ref ([]) ? scalar(@$device_list) : 1;
- if ($device_num > $device_times) { print "Out of device scope, supply right device num pls!\n"; }
- else {
- my $device_name = ($device_times == 1)?$device_list->{device_name}:$xml_data->{device}[$device_num-1]->{device_name};
- my $config = <<END;
- system-view
- ip router $device_name
- undo shutdown
- return
- END
- print $config;
- }
- <>;
- __DATA__
- <function funcname="gray_list" mode="predefined" no="no">
- <task_name>20130506113902_989513309</task_name>
- <device>
- <device_name>202.197.12.199</device_name>
- <interface_name>gei-0/2</interface_name>
- <commited_information_rate>5000</commited_information_rate>
- <host>
- <ip>192.168.1.1</ip>
- <mask>255.255.255.0</mask>
- </host>
- </device>
- <device>
- <device_name>202.197.12.200</device_name>
- <interface_name>gei-0/2</interface_name>
- <commited_information_rate>5000</commited_information_rate>
- <host>
- <ip>192.168.1.1</ip>
- <mask>255.255.255.0</mask>
- </host>
- </device>
- </function>
复制代码 楼主想要的可能是这个,把话费给我吧! |
|