LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 03-30-2005, 03:12 AM   #1
raumohir
LQ Newbie
 
Registered: Mar 2005
Posts: 2

Rep: Reputation: 0
error redirection


Does anyone know why using '2>' to do error redirection wouldn't work? I'm using a bash shell (I'm pretty sure), and typing:

$ ls blah 2> errors

where blah doesn't exist. I thought this would produce no output and send an error message into a file called 'errors'. But what I get back instead is:

ls: blah: No such file or directory
ls: 2: No such file or directory

The file 'error' is empty. Can anyone please help? Thanks!
 
Old 03-30-2005, 03:20 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

You are probably using a (t)csh shell, not a bash shell:

With (t)csh:
> ls blah
ls: blah: No such file or directory
> ls blah 2> errors
ls: blah: No such file or directory
ls: 2: No such file or directory

With bash:
$ ls blah
ls: blah: No such file or directory
$ ls blah 2> errors
$

Check your /etc/passwd entry and look what shell you start with.

Hope this helps.
 
Old 03-30-2005, 08:16 AM   #3
bru
Member
 
Registered: Sep 2003
Location: South Carolina
Distribution: Ubuntu, CentOS, BT4, Debian
Posts: 132

Rep: Reputation: 15
or an easy 'echo $SHELL' will tell you wher e your shell is located.
ie:
/bin/bash = bash
/bin/sh = bourne
/bin/... = others

HTH
 
Old 03-30-2005, 08:30 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

Be carefull with the echo $SHELL command:

Started with a bash shell:

$ echo $SHELL
/bin/bash
$ tcsh
> echo $SHELL
/bin/bash

As you can see in the above example: Im running a tcsh shell, not a bash shell (as given by the second echo $SHELL).
 
Old 03-30-2005, 12:13 PM   #5
raumohir
LQ Newbie
 
Registered: Mar 2005
Posts: 2

Original Poster
Rep: Reputation: 0
thanks!

Thanks everyone, turns out it was a tcsh shell, as you guessed. I didn't know tcsh didn't support error-stream-only redirection. Thanks for the help!
 
  


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
BASH scripting I/O redirection error blinux1 Programming 13 03-18-2008 08:21 PM
what is output redirection? LinuxPadawan General 5 05-18-2005 12:53 PM
Port 80 redirection omlex Linux - Security 1 02-20-2005 03:22 PM
redirection in C pantera Programming 2 08-11-2004 01:06 PM
Device Redirection CPUNeck Linux - Newbie 1 12-20-2001 01:27 PM


All times are GMT -5. The time now is 05:26 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