delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/14/08:46:47

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Something unusual about cat
Date: Fri, 14 Jan 2000 13:54:13 +0200
Organization: NetVision Israel
Lines: 39
Message-ID: <387F0E65.FBB25EC8@is.elta.co.il>
References: <85mnn0$uc1$1 AT enyo DOT uwa DOT edu DOT au>
NNTP-Posting-Host: ras1-p25.rvt.netvision.net.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 947850952 4396 62.0.172.27 (14 Jan 2000 11:55:52 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 14 Jan 2000 11:55:52 GMT
X-Mailer: Mozilla 4.7 [en] (Win98; I)
X-Accept-Language: en,ru,hebrew
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

DIAMOND Mark wrote:
> 
> I use Mathematica (the Wolfram package) running under Win-95. Mathematica
> allows one to read data through a pipe or shell command using
>     ReadList["!comand1 files | command2 ...."]
> 
> so that the standard output from the command is taken as the input to
> Mathematica. Whenever cat (GNU textutils 1.22) is the last command in piping
> process, or is the only command, no input is read into Mathematica. A
> failure example is
> 
> ReadList["!cat file1 file2"]

Do file1 and file2 have Unix-style end-of-line format?  That is, do they have
the Unix-standard single LF character at the end of each line, or do their
lines end with the DOS-standard CR-LF pair?

If these files have Unix-style end-of-line format, then I'd say this is a bug
in Mathematica: it doesn't support such text files on DOS/Windows.

> and yet if I use "sed" (GNU sed version 3.02) to do nothing more than put
> the standard input on the standard output, as in
> 
> ReadList["!cat file1 file2" | sed -n -e p "]
> 
> everything is OK and file1 and file2 are concatenated together and become
> the input for Mathematica.

Sed produces a DOS-style end-of-line format (for complex reasons I won't get
into here), even if the input file was in Unix format.  In contrast, cat does
not alter the end-of-line format of its input, since cat is frequently used
to copy files, and should then produce an identical copy.  Most (all?) other
programs from the Textutils package also leave the end-of-line format
intact.  You don't say what were the other commands you tried to use, but if
they were all from Textutils, I'd expect the output to have the end-of-line
format of the original input file.

You can try the utod program supplied with DJGPP to see whether converting
the files into DOS format pacifies Mathematica.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019