Solved

Problems with redirection

Posted on 2002-07-23
9
200 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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 50 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses

635 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