LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2011, 12:38 PM   #1
Batistuta_g_2000
Member
 
Registered: Oct 2011
Posts: 85
Blog Entries: 1

Rep: Reputation: Disabled
SRDERR and STDOUT


So I want to my script to log errors and operations:
Code:
OPLOG=$[ 2>&1 1>operations.txt ]
so if I do:

Code:
 if [[ -n "$bfilename" ]]; then $OPLOG
it will write to the txt file......but doesn't work, any ideas what I#m doing wrong?
 
Old 11-01-2011, 01:18 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Well, a $[ is, as far as I can recall, not a valid bash construct so. if you're using bash, your OPLOG variable setting would report error that the test function ([ is just an alias for test where you used it.) was improperly invoked. I think what you want is:

OPLOG=' &>operations.txt' (Those are single-quotes, not back-quotes.)

and that, too, would cause an error in your proposed if statement since all OPLOG does is direct output to your log file, and your then clause contains no output generating statement. (Also, you failed to terminate the if with a required fi, but that may be just because you failed to include all of your script.

I'd suggest you look at the info bash documentation, carefully reading the section about the set command (Found in the Modifying Shell Behavior section [4.3] in the Shell Commands [4] group.) with particular attention to the -v and -x values.

Last edited by PTrenholme; 11-01-2011 at 01:19 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect standard stdout to multi stdout ( Bash )? john.daker Programming 4 11-04-2008 12:20 AM
Stdout SlacUser Linux - General 4 06-28-2007 10:07 AM
redirecting stdout to /dev/null and stderr to stdout? Thinking Programming 1 05-18-2006 03:36 AM
what is stdout stefaandk Linux - Newbie 1 09-06-2005 08:20 PM
stdout with tk? sk8guitar Programming 1 07-30-2003 03:48 PM


All times are GMT -5. The time now is 07:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration