Spasticus has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to connect to a series of machines via ssh, call a script on each that returns formatted data and process the data in turn. This sub is used to retrieve the data from each machine and store it in a hash...
Which is called from within:sub get_remote_file { print "Retrieving data file..."; my @site_data; chomp( @site_data = `$conx` ); if ( $? >> 8 ) { print "Failed!\n"; } else{ print "Success!\n"; } for $line( @site_data ) { ( $name, $filepath, $mod, $md5 ) = split( "\,", $line ); $site_data{$name} = ["$filepath", "$mod", "$md5"]; } @site_data = (); }
foreach $client ( @clients ) { my ( %site_data, %office_data ); print "Performing Sentinel check on $client\n"; get_client_configs( $client ); print "Retrieving data from site...\n"; get_remote_file; generate_local_data; compare_files; print "Completed Sentinel check on $client\n"; }
get_client_configs updates the $conx variable among other things. The $conx variable holds the connection string, eg 'ssh host ~/myscript'.
The problem I'm having is that the first time through the loop everything works fine and the hash is properly populated. However on every subsequent call the @site_data ends up with a single element containing all the data returned from the script on the remote machine. As you can see it screws up the populating of the hash.
Can anyone please help? Before you say it I cannot install any modules to help with this, it's not my machine.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Processing data from SSH stream
by roboticus (Chancellor) on Apr 12, 2007 at 09:46 UTC | |
|
Re: Processing data from SSH stream
by Anonymous Monk on Apr 12, 2007 at 03:57 UTC | |
by Spasticus (Initiate) on Apr 12, 2007 at 05:27 UTC | |
|
Re: Processing data from SSH stream
by Krambambuli (Curate) on Apr 12, 2007 at 10:13 UTC | |
by Spasticus (Initiate) on May 11, 2007 at 01:00 UTC | |
by snoopy (Curate) on May 11, 2007 at 01:34 UTC |