[oclug] Scripting with Arrays ??

Brad Barnett bbarnett at L8R.net
Sat Mar 16 06:17:37 EST 2002


On Fri, 15 Mar 2002 21:29:19 -0500
Dave Lewis <dlewis at ottawa.com> wrote:

> I have a question about arrays.  I'm not toooo familiar with bash so
> this question will probably seem
> stupid to those that script with it daily...
> 
> My problem is that I have the out put of a ps / awk command as follows
> 
> ps aux | awk '/glftpd/ {print $2}'
> 1287
> 9932	
> 339
> 
> and I want to add those numbers which are pid's, to an array in a script
> to use later to kill the processes, like
> 
> kill -9 $PIDNUM[$INDEX]
> 
> I'm planning on a fixed array for let's say 10 values since that is the
> max allowd on this particular ftp.
>  From what I  understand I need the array like
> 
> set PIDNUM = (0 0 0 0 0 0 0 0 0 0)
> 
> but I don't the language well enought to get the output from the awk
> into the array .
> 
> Can anyone help ?
> 
> Dave
> 

Before you reinvent the wheel, have you tried :

killall glftpd

instead?



More information about the OCLUG mailing list