FedoraForum.org - Fedora Support Forums and Community
Results 1 to 9 of 9
  1. #1
    eichar Guest

    Ambiguous output redirect

    In Fedora 10, using the csh shell, when I enter the following command:
    Code:
    ls *.txt > list.tm1 2 > list.stderr
    I am getting an error:
    Ambiguous output redirect.
    From examples I have seen, this should work. I think that the the shell is passing the "2" as an argument to ls, instead of taking it as a specification for redirecting the standard error. What can I do?
    [Note, bash yields a different error]

  2. #2
    scottro's Avatar
    scottro is offline Retired Community Manager -- Banned from Texas by popular demand.
    Join Date
    Sep 2007
    Location
    NYC
    Posts
    8,120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Argh, I don't remember how to do it, but I am fairly sure that with csh you have to do something else. I just vaguely remember doing something as root on FreeBSD, where root's shell is csh, and wanting to redirect, and it wasn't working properly.

    Sorry I can't give more help--I think I solved it by googling for csh redirect or csh stderr or something like that.
    --
    http://srobb.net

  3. #3
    Join Date
    Dec 2004
    Location
    Canada
    Age
    35
    Posts
    9,221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I haven't used csh in a very long time, but I know in bash (regular "sh") you need to place the "2" and the ">" characters next to each other like this:
    Code:
    ls *.txt > list.tm1 2> list.stderr
    does that help?
    [+] My open source software and blog
    [+] Some of my howtos: (for full list, click here)

  4. #4
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    4,991
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    bash -c 'ls *.txt > list.txt 2> list.stderr'


    you can't do the same in csh, best you can do is redirect everything to 1 file

    Code:
    ls *.txt >& list.txt
    http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/

  5. #5
    eichar Guest
    Got it thanks.

  6. #6
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    10,377
    Mentioned
    134 Post(s)
    Tagged
    0 Thread(s)
    You can do this in csh, like this:
    Code:
    (ls *.txt > list.tm1) >& list.stderr

  7. #7
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    4,991
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RupertPupkin
    You can do this in csh, like this:
    Code:
    (ls *.txt > list.tm1) >& list.stderr
    ooh, very clever Thanks for the correction, in my defence, I haven't used csh/tcsh for many years.

    An explanation of why that works is here
    http://www.faqs.org/faqs/unix-faq/fa...section-9.html

    Now,I bet you can't redirect just stderr (which I'll claim now is what I meant)

  8. #8
    Join Date
    Nov 2006
    Location
    Detroit
    Posts
    10,377
    Mentioned
    134 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sideways
    Now,I bet you can't redirect just stderr (which I'll claim now is what I meant)
    Sure you can:
    Code:
    (ls *.txt > /dev/tty) >& list.stderr

  9. #9
    Join Date
    Oct 2004
    Location
    London, UK
    Posts
    4,991
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, ok you win, although strictly speaking that's not really playing fair

    (he cheated by redirecting stdout to the terminal first, sneaky chap)

Similar Threads

  1. Redirect backup output to network printer
    By workaholicbe in forum Using Fedora
    Replies: 1
    Last Post: 18th March 2009, 11:45 AM
  2. Replies: 6
    Last Post: 10th December 2008, 06:00 AM
  3. Replies: 5
    Last Post: 1st June 2006, 03:12 AM
  4. How to redirect output to a file?
    By mus1402 in forum Servers & Networking
    Replies: 1
    Last Post: 5th February 2006, 06:11 AM
  5. BASH: How to redirect ping output to file?
    By funchords in forum Using Fedora
    Replies: 22
    Last Post: 27th December 2005, 04:34 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •