Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Problems with redirection

Posted on 2002-07-23
9
Medium Priority
?
201 Views
Last Modified: 2010-04-21
I have this comand

xxx > file.txt

after that there many persons doing something like

tail -f file.txt


My problem is that the command sends litle messages and is not imediatly write to the file. There is any way to redirection imediatly write to the text file the output of the command.

I don't have admin premictions.
0
Comment
Question by:oleber
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 7172022
The problem is likly that the xxx program uses the C stdio library, which knows the data is going to a file and buffers it.

Try
xxx | cat > file.txt
0
 
LVL 10

Author Comment

by:oleber
ID: 7172079
I'm using this code

perl -e 'for ($i=0; $i<100000; $i++) {print "$i\n";if ($i % 1000 == 0){sleep 1}}' | cat > lixo.txt & ; tail -f lixo.txt

So just must stop if $i end's on 000, it stops in diferent values



My unix version

> version
Machine hardware:   sun4u
OS version:         5.6
Processor type:     sparc
Hardware:           SUNW,Ultra-4

...
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 7172113
How busy is the machine? Maybe the job just isn't running continuously. Try a bigger sleep so you can tell the difference between machine business and intentional sleeps.

If this is buffering problem, you'll see things like the output being cut in the middle of a line.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Author Comment

by:oleber
ID: 7172120
It's what is happening. The numbers are beeing cut in the middle of a line.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 7172199
perl -e '$|=1;for ($i=0; $i<100000; $i++){print "$i\n";if ($i % 1000 == 0){sleep 1}}' | cat > lixo.txt & ; tail -f lixo.txt
0
 
LVL 10

Author Comment

by:oleber
ID: 7172217
sorry, i full you with the code
perl -e '$|=1;for ($i=0; $i<100000; $i++){print "$i\n";if ($i % 1000 == 0){sleep 1}}'

What I have is a C/C++ program, the perl just sorce was an example of a command.

please, is there a way of doing something similar to $|=1 in C/C++.
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 150 total points
ID: 7172351
fflush()
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 7172747
and/or setbuf()
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7921664
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- PAQ, no points refunded

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0

Featured Post

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question