/[pxelator]/bin/smclp.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/smclp.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 466 - (show annotations)
Sun Jan 3 20:00:05 2010 UTC (14 years, 2 months ago) by dpavlin
File MIME type: text/plain
File size: 1292 byte(s)
added command-line options for debug and timeout

1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 # Dell's DRAC SM-CLP
7
8 use Data::Dump qw/dump/;
9
10 use Net::OpenSSH;
11 use Expect;
12 use Getopt::Long;
13
14 my $debug = 0;
15 my $timeout = 5;
16
17 GetOptions(
18 'debug!' => \$debug,
19 'timeout=i' => \$timeout,
20 ) or die $!;
21
22 my ( $uri, $command, $path ) = @ARGV;
23 die "usage: $0 login:passwd\@host show /system1\n" unless $uri && $command;
24
25 my $ssh = Net::OpenSSH->new( $uri );
26 my ( $pty, $pid ) = $ssh->open2pty;
27 my $expect = Expect->init($pty);
28 $expect->raw_pty(1);
29 $expect->log_user(1) if $debug;
30
31 $expect->expect( $timeout, '$' );
32 $expect->send( "smclp\n" );
33
34 $expect->expect( $timeout, '>' );
35
36 my $data;
37
38 sub smclp {
39 my ( $command, $path ) = @_;
40
41 warn "smclp $command $path\n" if $debug;
42
43 $expect->send( "$command $path\n" );
44
45 $expect->expect( $timeout, '>' );
46
47 my $got = $expect->before;
48
49 my $section;
50
51 foreach ( split(/\r\n/, $got ) ) {
52 if ( m{(/.*):} ) {
53 $path = $1;
54 } elsif ( m{^\s{2}(\w+):} ) {
55 $section = $1;
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;
60 } else {
61 push @{ $data->{$path}->{$section} }, $1;
62 }
63 } else {
64 print "# IGNORE [$_]\n" if $debug;
65 }
66 }
67
68 warn "# data = ",dump $data;
69 }
70
71 smclp $command => $path;
72

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26