8 use Data::Dump qw/dump/;
19 'timeout=i' => \$timeout,
22 my ( $uri, $command, $path ) = @ARGV;
23 die "usage: $0 login:passwd\@host show /system1\n" unless $uri && $command;
25 my $ssh = Net::OpenSSH->new( $uri );
26 my ( $pty, $pid ) = $ssh->open2pty;
27 my $expect = Expect->init($pty);
29 $expect->log_user(1) if $debug;
31 $expect->expect( $timeout, '$' );
32 $expect->send( "smclp\n" );
34 $expect->expect( $timeout, '>' );
39 my ( $command, $path ) = @_;
41 warn "smclp $command $path\n" if $debug;
43 $expect->send( "$command $path\n" );
45 $expect->expect( $timeout, '>' );
47 my $got = $expect->before;
51 foreach ( split(/\r\n/, $got ) ) {
54 } elsif ( m{^\s{2}(\w+):} ) {
56 } elsif ( m{^\s{4}(.+)} ) {
57 if ( $section eq 'Properties' ) {
58 my ( $k, $v ) = split(/\s+=\s+/,$1,2);
59 $data->{$path}->{$section}->{$k} = $v;
61 push @{ $data->{$path}->{$section} }, $1;
64 print "# IGNORE [$_]\n" if $debug;
68 warn "# data = ",dump $data;
71 smclp $command => $path;