problem parsing process-output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem parsing process-output
# 1  
Old 07-24-2006
problem parsing process-output

HI all!

I have a problem parsing the output of another process. The output is like this (C):

Code:
 printf("\rCheck exist: %d/%d",idx,pBF->NBits());

The aim of the script I'm coding is to save in a separate file the last output line of first process.
This is the script now (Shell script):

Code:
nohup long_process | 
while read line ; do
echo $line  > stdout.file
done

The problem comes with the lines with carriage returns (\r), that they're not saved in the file.

I tried with $sed 's/\r/\n/g' , with $tr -r '\r' , etc,. with no result

Anybody can help me?
thanks
# 2  
Old 07-24-2006
If you want to remove the '\r' character you can do :
Code:
nohup long_process | tr -d '\r |
while read line ; do
echo $line  > stdout.file
done

If you prefer replacing '\r' by a new line :
Code:
nohup long_process | tr '\r' '\n' |
while read line ; do
echo $line  > stdout.file
done

Jean-Pierre.
# 3  
Old 07-24-2006
Thx Jean pierre, but your solutin seems to not work properly. First solution works ok, but lines with \r not appear in the file.

The second solution doesn't show any line, seems that while loop not read any line..
# 4  
Old 07-25-2006
If interests to somebody, I solved this problem changing the read line delimitier:

Code:
while read -d ':' line ; do


Because lines always end with : The \r delimitier does not work properly

Cheers
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing nsupdate's output

Anybody that's ever used nsupdate knows that it's error management is not very good. I have a wrapper script that when it's got all the information it needs launches the nsupdate command. This is my attempt at parsing the output to help support users quickly know if the command succeded or... (7 Replies)
Discussion started by: maverick72
7 Replies

2. Shell Programming and Scripting

Process List Parsing?

Most of the code I've seen is been listing processes or capturing process ids, etc. But here's what I need to do. Preferably in Korn shell. 1. do a ps -ef |grep tns |grep -v grep in order to get a list or Oracle listeners that are running. 2. parse the line into components which... (7 Replies)
Discussion started by: MRMonteith
7 Replies

3. Shell Programming and Scripting

Parsing Output of a Variable

i have a log file that contains something similar to this: one two three four five six seven eight nine ten eleven twelve thirteen fourteen one two three four five six seven eight nine ten eleven twelve thirteen fourteen one two three four five six seven eight nine ten eleven twelve... (3 Replies)
Discussion started by: SkySmart
3 Replies

4. Shell Programming and Scripting

parsing output

Can somebody provide a solution to parse the following; cat /tmp/xxx Name: QUE_REQU (o.mtaseast-o.dmart) (MTPost queue) Number of messages: 66446 (Age 686 min; Size 214 mb) Backlog (messages): 0 (Age 0 min) Name: QUE_REQU... (6 Replies)
Discussion started by: BeefStu
6 Replies

5. Shell Programming and Scripting

parsing ifconfig output

I'm trying to gather information on the interfaces on a large number of servers. If I run ifconfig I will get: eth0 Link encap:Ethernet HWaddr 00:50:56:A2:27:C1 inet addr:10.145.xxx.xxx Bcast:10.152.45.255 Mask:255.255.254.0 ----- eth1 Link... (2 Replies)
Discussion started by: C0ppert0p
2 Replies

6. Shell Programming and Scripting

parsing output of system()

Hi, From the above output of df command I need to parse only 43G (available space) and display it. root@localhost:> df -h /vol1/joy Filesystem Size Used Avail Capacity Mounted on /vol1/joy 180G 137G 43G 76% ... (3 Replies)
Discussion started by: cjjoy
3 Replies

7. Shell Programming and Scripting

Parsing output

I need to parse the following out put and determine if the USB is a DISK and whether or not it's External. If an HBA line contains "USB" then does the next line contain "DISK" and "External". 0:0,31,0: HBA : (aacraid,1) AAC SCSI 0,0,0: DISK : Adaptec ASR4800SAS Volu0001 ... (6 Replies)
Discussion started by: lochraven
6 Replies

8. Shell Programming and Scripting

parsing output

I have a file that contains the output of the ls -iR command, something like this: ./results: 2504641011 result_1410 2500957642 result_525 2504641012 result_1425 2500957643 result_540 ./tests/1: 2500788755 1 2500788743 1000 ./tests/2: 2500788759 3 2500788758 999 ... (6 Replies)
Discussion started by: looza
6 Replies

9. Shell Programming and Scripting

problem parsing output file

Hi Gurus, I am using the following code to parse the output of a file. This code basically parses the file and adds | at the end of each field. But I am getting it wrong in some cases. I have explained it below #----- parse output file, get each field position, ----- #----- and construct... (13 Replies)
Discussion started by: ragha81
13 Replies

10. Shell Programming and Scripting

parsing output from ls command

I have to test the directory name which is obtained from for dir in `ls -l|grep $9 ' i need to check whether it is directory ( if yes, I have to check the first 3 character fo the directory how can I do that? Please help me thanks (3 Replies)
Discussion started by: ajaya
3 Replies
Login or Register to Ask a Question