rcp error output question

This is a discussion on rcp error output question within the Linux Programming forums, part of the Platform Specific Boards category; Hello, I have a question regarding the rcp command. If the file I'm trying to copy doesn't exist, rcp's output ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    4

    rcp error output question

    Hello, I have a question regarding the rcp command.

    If the file I'm trying to copy doesn't exist, rcp's output ("file or directory does not exist") appears on the screen, but I'd like this output to be appended to a file.
    The usual way,
    rcp file_to_be_copied file_to_copy_to >> output.txt
    doesn't work. (the message only appears on screen, not in the output.txt file)

    Any ideas?

    Thank you.

  2. #2
    Amazingly beautiful user.
    Join Date
    Jul 2005
    Location
    If you knew I'd have to kill you
    Posts
    254
    Here's your problem. ">>" only redirects stdout to the file. Your error message is being sent to stderr.
    So, what you want is,
    Code:
    rcp file_to_be_copied file_to_copy_to 1>out.txt 2>err.txt
    cat out.txt >> err.txt
    cat err.txt >> output.txt
    This will take the console output (non errors), stick that onto the error messages, and finally, stick this into your output file (note, out.txt, err.txt are temprory files, overwritten every time).

    Implement this in your program however you want (i'd recommend "system();" calls personally).

    Or, if your doing a standard "sh" script, just stick it in your script.

    Enjoy your day.
    Programming Your Mom. http://www.dandongs.com/

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21