The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
parsing output from SQL querry ludvig Shell Programming and Scripting 7 10-23-2007 06:42 AM
parsing output from a diff command... kam Shell Programming and Scripting 5 05-30-2007 12:26 AM
problem parsing output file ragha81 Shell Programming and Scripting 13 03-21-2007 02:06 PM
parsing output from ls command ajaya Shell Programming and Scripting 3 05-10-2006 11:22 AM
HTTP Query Request & Parsing returned XML output jerardfjay Shell Programming and Scripting 15 05-18-2005 10:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-24-2006
victorin victorin is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 12
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 (permalink)  
Old 07-24-2006
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,433
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 (permalink)  
Old 07-24-2006
victorin victorin is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 12
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 (permalink)  
Old 07-25-2006
victorin victorin is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 12
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:46 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0