I'm using cron and fetchmail to poll a mail server on a regular basis. For sake of redundant record keeping, I need to log the output of the fetchmail command every time it is run. This is not hard, as all I need to do is redirect it to a log file with a >> in the cron line.
My issue is that this method produces the file I want, but there are no time or date stamps. I wrote a small script in perl that does nothing but take a line as input, append a time stamp to the front, then print the combined line. So in theory, all I need to do is pass the output of fetchmail into this perl script then redirect its output into a log file.
So now I have 2 questions:
1. When I pass the output of fetchmail (on the command line) into this script (addts) with:
I get this error:
entering the password I get:
I assume this has something to do with the shell fetchmail is being run in? Just calling fetchmail works fine.
2. I can redirect the output of fetchmail into the addts script, but how can I then redirect that output into a log file all on one line? Would it be something like:
My issue is that this method produces the file I want, but there are no time or date stamps. I wrote a small script in perl that does nothing but take a line as input, append a time stamp to the front, then print the combined line. So in theory, all I need to do is pass the output of fetchmail into this perl script then redirect its output into a log file.
So now I have 2 questions:
1. When I pass the output of fetchmail (on the command line) into this script (addts) with:
Code:
fetchmail >(addts)
I get this error:
Code:
helpdesk@helpdesk:~/tmp$ fetchmail >(addts)
2008-04-25 14:20:301 :Enter password for helpdesk@/dev/fd/63:
entering the password I get:
Code:
fetchmail: couldn't find canonical DNS name of /dev/fd/63 (/dev/fd/63): Name or service not known
fetchmail: Query status=11 (DNS)
I assume this has something to do with the shell fetchmail is being run in? Just calling fetchmail works fine.
2. I can redirect the output of fetchmail into the addts script, but how can I then redirect that output into a log file all on one line? Would it be something like:
Code:
fetchmail >(addts) > logfile