LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-07-2010, 06:13 AM   #1
Sabir_101
LQ Newbie
 
Registered: Sep 2010
Posts: 3

Rep: Reputation: 0
STDIN, STDOUT, STDERROR Redirection for scripting


Hi there,

I'm writing a script to execute bash commands in the PHP CLI. I would like to suppress errors from bash and write my own error message if an error occurs.

So far I have this (assuming log.txt doesn't exist!):

Code:
tac log.txt 2>/dev/null
Which works as expected, tac kicks up an error but the error is suppressed, but when I use this:

Code:
tac < log.txt 2>/dev/null
I get:

Code:
bash: log.txt: No such file or directory
The tac error is suppressed but bash still gives me a dirty error.

Does anyone know how to suppress this?
 
Old 09-07-2010, 06:19 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,136

Rep: Reputation: 230Reputation: 230Reputation: 230
Code:
(tac < log.txt) 2>/dev/null
 
1 members found this post helpful.
Old 09-07-2010, 06:21 AM   #3
Sabir_101
LQ Newbie
 
Registered: Sep 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Much appreciated! Thanks.
 
  


Reply

Tags
bash, redirection


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
tar, stdin or stdout evil_empire Linux - Newbie 3 06-20-2009 06:43 PM
Details of stdin and stdout pixellany Linux - Newbie 1 01-11-2006 01:21 PM
stdout stdin Furlinastis Linux - Newbie 3 08-11-2005 11:00 PM
stdout & stderror output nevx Linux - Newbie 1 05-03-2005 06:56 AM
stdin -> port -> stdout acid_kewpie Linux - Networking 5 04-12-2002 06:01 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration