Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I execute a system command within in AWK program?

Status
Not open for further replies.

hongtli

MIS
Jun 12, 2000
3
0
0
CA
Thanks a lot in advance!<br><br>I got an idea: when the AWK program scans a report file and finds a data entry that exceeds a threshlod, and I want to send an email to inform someone about this (using mailx command), I wonder if I can do it. if can, how to do it?
 
cat report ¦ awk ‘$n &gt; threshold {print $0}’ &gt; result<br>if [ -s result ]<br>then<br>cat result ¦ mailx -s &quot;MESSAGE” mail@address<br>else<br>echo “None exceeds threshold”<br>fi<br><br>Notes: - &quot;-s&quot; is the test in korn shell for file exists and is greater than zero. <p>Ged Jones<br><a href=mailto:gedejones@hotmail.com>gedejones@hotmail.com</a><br><a href= > </a><br>
 
Is there a way to execute unix shell commands from inside an awk program?&nbsp;&nbsp;Thanks in advance.<br><br>&nbsp;~aithosn8
 
I have found an answer for my own question.&nbsp;&nbsp;To run a system command from inside an awk program simply follow the syntax below where command is the system command being run.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system(&quot;command&quot;)<br><br>&nbsp;~aithosn8
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top