Philipp wrote:

> [2024-03-05 17:07] Simon Hoffmann <open...@list.simonhoffmann.net>
> > hmm... Based on Philipps idea I have modified my script as follows:
> >
> >
> >
> > #!/bin/bash
> >
> > cat - > /tmp/notfallemail
> 
> Have you notice that this is racy? A better (not elegant solution) is
> something like:
> 
> mail=`cat`

Yeah, in the final version I will do this differently. Writing stdin to a file 
gave
me the opportunity to inspect the file.


> 
> > from=`cat /tmp/notfallemail | head -n 50 | grep -i ^From`
> > from=${from// /+}
> >
> > subject=`cat /tmp/notfallemail | head -n 50 | grep -i ^Subject`
> > subject=${subject// /+}
> >
> >
> > out=`curl -g 
> > "https://smsgw01/cgi-bin/sms_send?text=Neue+Notfall+Email+von+$from+mit+Betreff+$subject"`
> >
> > exit 0
> >
> >
> > Stdin works. The SMS message now contains the From and the Subject header. 
> > However, OpenSMTPd still complains with "mda exited prematurely".
> 
> This sounds strange, are you sure that this error is produced while
> using this exact version of the script?

Yes, I have double checked that. 

> 
> >
> > If I however change the script to the following, while the message OpenSMTPd
> > complains about is still in the queue and pending
> >
> > #!/bin/bash
> >
> > cat - > /dev/null
> >
> > out=`curl -g "https://smsgw01/cgi-bin/sms_send?text=Neue+Notfall+Email"`
> >
> > exit 0
> >
> >
> > and then issue smtpctl schedule all, then OpenSMTPd reports a successful 
> > delivery and removes the mail from the queue.
> >
> >
> > Any ideas?
> 
> A wild guess is that your fs under '/tmp' is to small and cat gets a pipe
> error. Specialy when you have multible instances of your script running
> this is quite hard to detect.

There is ~150GB of free space on disk and /tmp is just a folder on /, no 
separate
filesystem. 




Simon

Attachment: signature.asc
Description: PGP signature

Reply via email to