LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-25-2008, 01:17 PM   #1
vortmax
Member
 
Registered: Nov 2005
Posts: 91

Rep: Reputation: 17
redirecting output into new script


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 now I have 2 questions:

1. When I pass the output of fetchmail 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)
is this an issue with the script running in it's own shell?

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
 
Old 04-25-2008, 03:16 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
You don't re-direct into a process using the > operator. You use a pipe, e.g.
Code:
program1 | program2
> is for re-directing into files, not processes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A little help with redirecting output tybalt Linux - Newbie 1 08-04-2007 10:08 PM
redirecting output using > cmk77 Slackware 8 11-10-2006 02:08 AM
Redirecting output from XEV 3saul Linux - Software 1 02-26-2006 01:14 PM
Redirecting output of a shell script raj_deep2k1 Linux - General 2 01-20-2006 07:38 AM
redirecting xmms output durden2.0 Linux - Software 0 03-06-2004 07:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration