oleber
asked on
Problems with redirection
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.
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.
ASKER
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
...
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
...
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.
If this is buffering problem, you'll see things like the output being cut in the middle of a line.
ASKER
It's what is happening. The numbers are beeing cut in the middle of a line.
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
ASKER
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++.
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++.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and/or setbuf()
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
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
Try
xxx | cat > file.txt