This may be somewhat OT, but I've been struggling with this for a while. I have an awk script running on an embedded box which periodically sends email. The email sending part works. I am having trouble reading the status of the sendmail command. I need to be able to parse the output of sendmail and look for a "250 OK" to make sure the mail was sent correctly.

This snippet should work. Unfortunately on busybox awk piping a shell command to getline doesn't seem to work. Is this a gawk extension? Is it unimplemented in busybox? Or is my syntax wrong? Regardless, can anyone offer a workaround?

                       sent = 0
                       sendmail = "cat /tmp/loc | sendmail -t -v"
                       while ( sendmail | getline res > 0) {
                               if ( res ~ /250 OK/ ) {
                                       sent = 1
                                       }
                               }
                       if (sent == 0) {
                               print "sending failed"
                               }
                       else {
                               print "sent successfully"
                               }
                       close(sendmail)

--

  o__
  ,>/'_         o__
  (_)\(_)       ,>/'_          o__
A day may come  (_)\(_)         ,>/'_      o__
when the courage of men fails, (_)\(_) ,>/'_ when we forsake our friends and break all (_)\(_)
bonds of fellowship, but it is not this day.
It is not this day!
This day we ride!

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to