List Info

Thread: Search for a specific line and run a command against it in perl




Search for a specific line and run a command against it in perl
user name
2005-12-20 19:48:48
Hi Paul,

Here is the additional lines that I added them in after
taking your
suggestion.  However, I'm still not able to pass the stdout
to an array
& then read and parse it to get a specific line.   Could
you take a
look & help me out?

use strict;
use warnings;
my $CLI_PATH="/bin/clui";
my $hostFile = "test.out";
open (fhHostFile, $hostFile) || die "Cannot open
$hostFile : $!n";

while (<fhHostFile>) {
        my $hostInfo=$_;
        next unless $. >3; # skip the 1st 3 tab
        my host_info=split /|/, $hostInfo;
        my output = `$CLI_PATH -cmd retrieve.host  -s
file:admin_passwd -ID NM:$host_info[2]`;
open (fhOutputLines, output) || die "Cannot read output :
$!n";
   while (<fhOutputLines>) {
            my $output = $_;
            my $appID = `grep "^[ ]*|[0-9]" output |
awk -F'|' '{print
$2}'`;
            my $cmd = sprintf("%s -cmd host.info  -s %s
 -ID %s",
                              $CLI_PATH,
                              
"file:admin_passwd",
                               $appID);
           print "Running: $cmdn";
           system ($cmd);
    }
    close (fhOutputLines);

} 

Thx much,
-Chris

Search for a specific line and run a command against it in perl
user name
2005-12-20 21:04:47
lazyboy wrote:
> Hi Paul,
>
> Here is the additional lines that I added them in after
taking your
> suggestion.  However, I'm still not able to pass the
stdout to an array
> & then read and parse it to get a specific line.  
Could you take a
> look & help me out?
>
> use strict;
> use warnings;
> my $CLI_PATH="/bin/clui";
> my $hostFile = "test.out";
> open (fhHostFile, $hostFile) || die "Cannot open
$hostFile : $!n";
>
> while (<fhHostFile>) {
>         my $hostInfo=$_;
>         next unless $. >3; # skip the 1st 3 tab
>         my host_info=split /|/, $hostInfo;
>         my output = `$CLI_PATH -cmd retrieve.host  -s
> file:admin_passwd -ID NM:$host_info[2]`;
> open (fhOutputLines, output) || die "Cannot
read output : $!n";

What the... didn't I just reply to this somewhere?  Are you
trying to
maintain two conversations in two different groups about the
same
topic?  Please don't do that.  Choose a group and stick with
it.

See my comments in
http://groups.google.com/group/perl.beginners/browse_frm/t
hread/d390731b8fe86c50/579a80de4c606482#579a80de4c606482

(My fault for not realizing I was talking to the same person
about the
same problem in two different threads, I suppose)

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )