Email and ‘echo’ on Unix

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Email and ‘echo’ on Unix

  • Creator
    Topic
  • #49950
    Richard Hart
    Participant

      We encountered an error with using the ‘echo’ command when the message was very large.

      eg

      exec echo “$myMailData” | mail -s $mySubject $myGroup

      I’ve replaced the ‘exec echo’ with a call to a procedure in our library code.  This procedure uses a pipe and puts.

      eg

      proc libEmail {aGlobals aTo aSubject aBody} {

             #

             # This procedure was created when ‘echo’ failed with a message that was too

             # large!

             # Open a pipe to the mail command

             #

         if {[catch {set myMailPipe [open “| mailx -s “$aSubject” “$aTo”” w]} myCatchErr]} {

             Print $aGlobals “libEmail: Cannot open pipe for [To: $aTo; Subject: $aSubject]! $myCatchErr ” E

             return {}

         }

             #

             # Write the email

             #

         if {[catch {puts $myMailPipe $aBody

                      close $myMailPipe} myCatchErr]} {

             Print $aGlobals “libEmail: Cannot send mail for [To: $aTo; Subject: $aSubject]! $myCatchErr” E

             return {}

         }

         return ‘OK’

      }

    • The forum ‘Cloverleaf’ is closed to new topics and replies.