SUMMARY: awk script fails

From: Francis, Rick <Rick.Francis_at_Transora.com>
Date: Tue Jun 12 2001 - 13:26:52 EDT
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0F364.DE9C2C70
Content-Type: text/plain

ok. the silence from the list pushed me to get this script working, and i
did.
the problem was not with the system function, but with the $CMD in the
system call.
here's the corrected system calls:
...
	if(error[$0]) 
	{
	system("cp -p err.alert err.alert.`date +%m%d%y.%S`");
	system("mailx -s "$0" rick.francis@transora.com</dev/null");
	}
}' $F0 $F1
exit 0

Would ANyone have an idea how to enhance this script by redirecting the name
of the file $0 matched in the email?

rf

__________________________
original post:
in this script, the printf works if $0 is returned, but the two (2)
system("$CMD") lines are skipped and not read; any ideas, any help?
______________________________________________________
#!/usr/bin/sh
P=/usr/bin
DATE='date +%m%d%y.%S'
FF=/usr/home/rfrancis
F0=/var/adm/messages
F1=/var/log/syslog
/usr/bin/awk '
	BEGIN {
		error["full"] = 1;
		error["fault"] = 1;
		}
{
	if(error[$0]) 
	{
	printf("Match: %s\n",$0);
	system("$P/cp -p $FF/err.alert $FF/err.alert.$DATE");
	system("$P/mailx -v -s err.alert
rick.francis@transora.com<err.alert");
	}
}' $F0 $F1
exit 0
------------------------------------------------------

what is it about the system("$CMD") call; should it be something else; i've
tried exec, command???
thanks again.
rf



The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited.  If you received
this in error, please contact the sender and delete the material from any
computer.

------_=_NextPart_001_01C0F364.DE9C2C70
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>SUMMARY: awk script fails</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>ok. the silence from the list pushed me to get this =
script working, and i did.</FONT>
<BR><FONT SIZE=3D2>the problem was not with the system function, but =
with the $CMD in the system call.</FONT>
<BR><FONT SIZE=3D2>here's the corrected system calls:</FONT>
<BR><FONT SIZE=3D2>...</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>if(error[$0]) </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>system(&quot;cp -p err.alert err.alert.`date =
+%m%d%y.%S`&quot;);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>system(&quot;mailx -s &quot;$0&quot; =
rick.francis@transora.com&lt;/dev/null&quot;);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>}</FONT>
<BR><FONT SIZE=3D2>}' $F0 $F1</FONT>
<BR><FONT SIZE=3D2>exit 0</FONT>
</P>

<P><FONT SIZE=3D2>Would ANyone have an idea how to enhance this script =
by redirecting the name of the file $0 matched in the email?</FONT>
</P>

<P><FONT SIZE=3D2>rf</FONT>
</P>

<P><FONT SIZE=3D2>__________________________</FONT>
<BR><FONT SIZE=3D2>original post:</FONT>
<BR><FONT SIZE=3D2>in this script, the printf works if $0 is returned, =
but the two (2) system(&quot;$CMD&quot;) lines are skipped and not =
read; any ideas, any help?</FONT></P>

<P><FONT =
SIZE=3D2>______________________________________________________</FONT>
<BR><FONT SIZE=3D2>#!/usr/bin/sh</FONT>
<BR><FONT SIZE=3D2>P=3D/usr/bin</FONT>
<BR><FONT SIZE=3D2>DATE=3D'date +%m%d%y.%S'</FONT>
<BR><FONT SIZE=3D2>FF=3D/usr/home/rfrancis</FONT>
<BR><FONT SIZE=3D2>F0=3D/var/adm/messages</FONT>
<BR><FONT SIZE=3D2>F1=3D/var/log/syslog</FONT>
<BR><FONT SIZE=3D2>/usr/bin/awk '</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>BEGIN =
{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>error[&quot;full&quot;] =3D 1;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>error[&quot;fault&quot;] =3D 1;</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>}</FONT>
<BR><FONT SIZE=3D2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>if(error[$0]) </FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>{</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>printf(&quot;Match: %s\n&quot;,$0);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>system(&quot;$P/cp -p $FF/err.alert =
$FF/err.alert.$DATE&quot;);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
SIZE=3D2>system(&quot;$P/mailx -v -s err.alert =
rick.francis@transora.com&lt;err.alert&quot;);</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=3D2>}</FONT>
<BR><FONT SIZE=3D2>}' $F0 $F1</FONT>
<BR><FONT SIZE=3D2>exit 0</FONT>
<BR><FONT =
SIZE=3D2>------------------------------------------------------</FONT>
</P>

<P><FONT SIZE=3D2>what is it about the system(&quot;$CMD&quot;) call; =
should it be something else; i've tried exec, command???</FONT>
<BR><FONT SIZE=3D2>thanks again.</FONT>
<BR><FONT SIZE=3D2>rf</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=3D2>The information transmitted is intended only for the =
person or entity to which it is addressed and may contain confidential =
and/or privileged material.&nbsp; Any review, retransmission, =
dissemination or other use of, or taking of any action in reliance =
upon, this information by persons or entities other than the intended =
recipient is prohibited.&nbsp; If you received this in error, please =
contact the sender and delete the material from any =
computer.</FONT></P>

</BODY>
</HTML>
------_=_NextPart_001_01C0F364.DE9C2C70--
Received on Tue Jun 12 18:26:52 2001

This archive was generated by hypermail 2.1.8 : Wed Mar 23 2016 - 16:24:56 EDT