Re: IDL> bug in SPAWN [message #3854] |
Mon, 10 April 1995 00:00  |
Fergus Gallagher
Messages: 41 Registered: January 1995
|
Member |
|
|
Serdar Manizade <manizade@aol3.wff.nasa.gov> wrote:
> I have seen behavior from SPAWN that may or may not have anything
> to do with your problem. (I am now running IDL3.6.1a under Solaris2.3)
> I was doing something like:
> SPAWN,'ls *.dat', filelist
> print,filelist
> This would look fine on the screen, but then I would try:
> openr,lun,/get,filelist(0)
> and I would get a message saying file not found. A clue to the
> problem was revealed by:
> print,strlen(filelist)
> filelist(0) was much longer than any of filelist(1:*). The problem
> was due to the initialization of my shell that was created by SPAWN.
> The quick solution (which is what I implemented) is to intercept the
> undesired characters thus:
> SPAWN,'date ; ls *.dat',filelist
> filelist=filelist(1:*)
>
> For other applications where I did not need the shell (for example
> when I did not have any wildcards in my command), then SPAWN,/noshell
> would also work.
>
> Fergus Gallagher <F.Gallagher@nerc.ac.uk> wrote:
>>
>> I am using IDL 3.6.1 under solaris 2.3. When I try
>>
>> IDL> spawn,command,out
>> IDL> print,'*'+out
>>
>> then the FIRST line of 'out' has the '*' missing. Closer inspection
>> shows that there is an extra character 13 at the start of out(0).
>>
>> This does *not* occur using the same version of IDL under SunOs 4.1.3.
>>
>> Can anyone report the same effect under any other operating system?
>>
>> It is not clear to me whether the bug is in the OS or in IDL.
>>
I think you've hit the nail on the head.
When I try
ls | wc
I get one byte fewer than
csh -c ls | wc
This is under Solaris 2.3 and 2.4. Under SunOS 4.1.3, they both give the
same result. ( I checked that 'source .cshrc | wc' gave a zero result on
all platforms, since our .cshrc are OS dependent)
So, to answer my own original question, the bug appears to be in the OS,
not IDL. Serdar's fix would seem to be a wise one for any applications
developers to adopt, viz
spawn,'date;...',out
out = out(1:*)
which absorbs any erroneous characters into the output from date.
Fergus
CC: Floating Point Systems
=================================================
| Fergus Gallagher |
| Remote Sensing Applications Development Unit |
| British National Space Centre |
| Monks Wood |
| Huntingdon PE17 2LS / UK |
| |
| F.Gallagher@nerc.ac.uk |
| http://uh.nmt.ac.uk/bnsc/fgg.html |
=================================================
|
|
|