LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-28-2006, 07:34 AM   #1
bartoni
LQ Newbie
 
Registered: Dec 2005
Posts: 6

Rep: Reputation: 0
can't capture 'at' command standard output to a file


Hello all,

I'm lost and hope someone with a clue can help me out.

If I do :
Code:
ls > test.txt
test.txt will contain the results from the command ls, no probs.

similary if I do :
Code:
at -l > test.txt
to see a list of scheduled jobs, test.txt contains the results as expected.

But... and here's my problem, if I do :

Code:
at -m -f myscript.sh now > test.txt
(to schedule my script) the output to the screen is :
Code:
warning: commands will be executed using /bin/sh
job 641 at 2006-02-28 13:35
But test.txt is empty!

How can I capture the output from the latter AT command, could the warning message be the reason that it is not sent to the file?


Hope someone can help, I'm really stuck with this.

Thanks.
 
Old 02-28-2006, 08:47 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
This should work:
Code:
at -m -f myscript.sh now > test.txt  2>&1
 
Old 02-28-2006, 10:34 AM   #3
bartoni
LQ Newbie
 
Registered: Dec 2005
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks! It works great.

Can you explain how?
 
Old 02-28-2006, 03:52 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
All that this command does is to redirect stdout (file decriptor 1) and stderr (file descriptor 2) to the file specified (test.txt). That means that all the output the command produces (normal output and eventual errors) is written to that file. For more info:
Code:
man bash
 
  


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
How do I forward standard and error output into same file? ivj Linux - Software 5 07-19-2005 08:30 PM
Capture 'make' Output to File Kenji Miyamoto Linux - Software 4 05-23-2005 05:56 PM
how to enumerate first line of text file to standard output? zero79 Linux - General 1 07-07-2004 06:37 PM
How to redirect standard output of piped command to log file andrewstr Linux - General 10 02-04-2004 02:07 PM
Help: Command Output to File. rvijay Linux - Newbie 3 09-30-2003 09:02 AM

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

All times are GMT -5. The time now is 09:40 AM.

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