Click here to get back home

STDOUT and STDERR redirection fails for forked process

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
STDOUT and STDERR redirection fails for forked process Peter 07-19-2007
Posted by Peter on July 19, 2007, 6:09 am
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Posted by Brian McCauley on July 20, 2007, 2:02 pm
Please log in for more thread options
>>
>> [snip]
>>
>> > if I print "$1\n",
>> > the file prints just fine. But, if I do something like print "$1 after
>> > \n", the whole output is messed up. If I print "before $1\n", nothing
>> > prints at all. If I print "before $1 after\n", only after prints.
>>
>> not really sure, but could be a rogue "\r" in $1,


> There
> is a rogue carriage return (0xd) in the string

> Is there something I can do to deal with this
> situation?


Repair the corrupted file:

perl -p -i -e 'tr/\r//d' bad_file


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas

Similar ThreadsPosted
STDOUT and STDERR redirection fails for forked process July 19, 2007, 4:06 am
daemonizing a process AND capture stdout, stderr January 14, 2005, 8:00 pm
Redirection whatever be the forked life May 15, 2006, 9:33 am
STDOUT redirection April 25, 2007, 4:40 pm
copy stdout fails with permission denied when stdout is redirected December 7, 2005, 1:15 pm
How to redirect STDOUT &STDERR? August 4, 2004, 3:21 am
selecting STDOUT AND STDERR December 20, 2004, 1:59 pm
pipe for stderr and stdout March 26, 2008, 7:17 pm
splitting stderr/stdout without using file April 27, 2006, 7:22 am
redirecting stdout/stderr to logfile May 24, 2006, 9:59 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap