Operating System - HP-UX
1834406 Members
1359 Online
110067 Solutions
New Discussion

Execute command in AWK and integrate with POSIX shell

 
yc_2
Regular Advisor

Execute command in AWK and integrate with POSIX shell

Hi,

I want to perform a backup automatically when the log files are full in informix.

Have though of an endless loop as follows:
while true
do
onstat -l | grep "U--" | awk '{if (NR==[number of table] [execute backup]}'.
done

The [execute backup] is a script using ontape command which already available.

Appreciate any advice on how to call the backup script within AWK or a better way to do it.


Thanks in advance,
YC
3 REPLIES 3
Carlos Fernandez Riera
Honored Contributor

Re: Execute command in AWK and integrate with POSIX shell

We need a little sample of data.

The sintax for executing inside awl is system

i.e.
while true
do
onstat -l | grep "U--" | awk '{if (NR==[number of table]) commd="echo " $1 ; system(commd) }'.
sleep 300
done
unsupported
James R. Ferguson
Acclaimed Contributor

Re: Execute command in AWK and integrate with POSIX shell

Hi:

Since you appear to be using 'awk' only to count the number of records, you could (simply) do:

...
onstat -l | grep "U--" | [`wc -l` = $N] && echo "ok"
...

Regards!

...JRF...


Zafar A. Mohammed_1
Trusted Contributor

Re: Execute command in AWK and integrate with POSIX shell

Leong,

I don't know what's the reason caputring the Log file and then issuing ontape command.

If you just issue ontape -a command it will copy all full logical logs automatically.

Thanks
Zafar