Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6771527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:26:34+00:00 2026-05-26T15:26:34+00:00

I want to put my program’s output into a file. I keyed in the

  • 0

I want to put my program’s output into a file. I keyed in the following :

./prog > log 2>&1

But there is nothing in the file “log”. I am using the Ubuntu 11.10 and the default shell is bash.

Anybody know the cause of this AND how I can debug this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:26:35+00:00Added an answer on May 26, 2026 at 3:26 pm

    There are many possible causes:

    • The program reads the input from log file while you try to redirect into it with truncation (see Why doesn't "sort file1 > file1" work?)
    • The output is buffered so that you don’t see data in the file until the output buffer is flushed. You can manually call fflush or output std::flush if using C++ I/O stream etc.
    • The program is smart enough and disables output if the output stream is not a terminal.
    • You look at the wrong file (i.e. in another directory).
    • You try to dump file’s contents incorrectly.
    • Your program outputs ‘\0’ as the first character so the output appears to be empty, even though there is some data.
    • Name your own.

    Your best bet is to run this application under a debugger (like gdb) or use strace or ptrace (or both) and see what the program is doing. I mean, really, output redirection works for the last like 40 years, so the problem must be somewhere else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a program that saves data to file and i want to put
I have threads in my program and I want to put character into stream
I want to put output information of my program to a folder. if given
I want to put random output from my result set (about 1.5 mil rows)
I want to put individual JComboBoxes into each cells of a JTable. ie. The
i want to put the id into the colorbox below this code nom works
I want to run a program with different configuration file, the program write with
i have a program with (.exe) type, i want to put a link in
I am writting a plugin for a program, and I want to put my
If I have output from two sources that I want to put together on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.