[Melbourne-pm] Writing array data to file with appended information

Mathew Robertson mathew.robertson at netratings.com.au
Thu Mar 26 23:35:48 PDT 2009


print UPDATE "$_\t1"


"ps auxww" will give you a process list, from which you can get the PID, 
so that you can call "kill -HUP <PID>"

Hope this helps,
Mathew Robertson

Camillo Pereira wrote:
> Hi,
>
> I have the following scenario where I need to extract node name 
> information based on certain conditions from an application, and write 
> the data out to a file and HUP the process concerned.  I have managed 
> to get to a certain point however need some advise.
>
> Script output:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> ## Cut down version of regex list
>
> my @critical_device_def = (
>     [AAA    => qr{...apb09}    ],
>     [BBB    => qr{...avggd09}    ],
>     [CCC => qr{...uytwop09}    ],
>     [DDD => qr{...loupoi09}   ]
>
> ); 
>
> my @DEVICE_LIST;
> my $file = "rules.txt";
> my @tokens;
>
> open(UPDATE, ">$file") || die "Can't open new file: $!\n";
>
> @DEVICE_LIST=`/opt/OV/bin/ovtopodump | awk '\$3 ~ 
> /^[a-z]+.*\.my\.domain\.com\.au/{print \$3}'| uniq`;
>
> foreach (@DEVICE_LIST)
>   {
>     for my $t (@critical_device_def)
>     {
>       my ($site, $device, $flag) = @$t;
>       if ($_ =~ m/\G($device)/gc)
>       {
>        
>         print UPDATE "$_" ;
>         next;
>       }
>        
>     }
>        
>   }
>
> =====
>
> The problem I am having is that at the print UPDATE line, I need to 
> append to the data a tab and the number 1.  With the current code, the 
> file output looks like this:
>
> cpploupoi09.my.domain.com.au <http://cpploupoi09.my.domain.com.au>
> cpqavggd09.my.domain.com.au <http://cpqavggd09.my.domain.com.au>
>
> however, I need the contents to be printed to the file in the format 
> below where the hostname then a tab and the number one is printed:
>
> cpploupoi09.my.domain.com.au <http://cpploupoi09.my.domain.com.au> 
> <tab_space> 1
> cpqavggd09.my.domain.com.au <http://cpqavggd09.my.domain.com.au> 
> <tab_space> 1
>
> What is the best way to do this?
>
> Also what is the best way to send a HUP signal to a running Unix process?
>
> Appreciate your help.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20090327/eae86c61/attachment.html>


More information about the Melbourne-pm mailing list