Hello monks!

I am having a bit of trouble with this script and I do appreciate your putting up with various iterations of it over the past few days. As you'll see I changed my approach from trying to work directly with the rather verbose output of this networking device (the 3par I've been carping about) I decide it might result in less headdesking if I dumped the output to a file and tried to parse that. And not for nothing but I've recently discovered the joys of perltidy.:-)

The trouble I'm currently facing is that I am having some trouble assigning the text to a hash. It starts spitting out quite a lot of output. I will include that at the end.

Without further ado, here is my latest attempt:

#!/usr/bin/perl use strict; use warnings; use IO::Pipe; use IO::Handle; use IO::File; my $system; my @systems = ( '3par-S400', '3par-E200' ); open( MYFILE, '>>data.txt' ); foreach $system (@systems) { my $output = run_command($system); while (<$output>) { next if (m/^$/); last if (m/^Press.*/); print MYFILE $_ . "\n"; } } close(MYFILE); open( MYFILE, '<data.txt' ); while (<MYFILE>) { next if (m/^$/); last if (m/^Press.*/); my ( $line, %seqs, $sequence, $date, $orig, $desg, $body ); if ( $line =~ /(\d+\-\d+\-\d+\s\d+\d+\ d+\ +)/ ) { $date = $1; } else { $seqs{$sequence} = "$date;$orig;$desg;$body"; } } sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $ssh_flags = "-l $user"; my $command = "statvv -ni"; my $space = " "; my $do_command = $protocol . $space . $ssh_flags . $space . $system . $space . $c +ommand; my $cmd = IO::Pipe->new; $cmd->reader($do_command); return $cmd; } close(MYFILE);


And this is a sample of the output I'm experiencing:

[bluethundr@cc126-200:~/perl] $:./3par-test5.pl Use of uninitialized value in pattern match (m//) at ./3par-test5.pl l +ine 29, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in hash element at ./3par-test5.pl line 30, + <MYFILE> line 1. Use of uninitialized value in pattern match (m//) at ./3par-test5.pl l +ine 29, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in hash element at ./3par-test5.pl line 30, + <MYFILE> line 2.



In reply to trouble assigning values to hash by bluethundr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.