Re: spawn and 'ls *.out' [message #50275] |
Wed, 20 September 2006 02:23 |
Paolo Grigis
Messages: 171 Registered: December 2003
|
Senior Member |
|
|
>> On Tue, 19 Sep 2006, queiny98@yahoo.com wrote:
>>
>>> Dear IDL experts,
>>>
>>> Can I use '*' and '?' in the UNIX commands through 'spawn'?
>>>
[...]
I would suggest to use file_search instead, it supports
wildcards characters.
Ciao,
Paolo
|
|
|
Re: spawn and 'ls *.out' [message #50276 is a reply to message #50275] |
Wed, 20 September 2006 01:16  |
Allan Whiteford
Messages: 117 Registered: June 2006
|
Senior Member |
|
|
F�LDY Lajos wrote:
>
> On Tue, 19 Sep 2006, queiny98@yahoo.com wrote:
>
>> Dear IDL experts,
>>
>> Can I use '*' and '?' in the UNIX commands through 'spawn'?
>>
>> When I try:
>>
>>> spawn, ['ls', 'data/2003????'], /noshell
>>
>> Cannot access data/2003????: No such file or directory
>>
>> I have files like '20030101', '20030102', etc. in this directory.
>> It seems 'spawn' interpolate '?' directly or literally. How could I let
>> IDL know?
>>
>> Thanks.
>>
>
> * and ? are evaluated by the shell. ls (and any other program) gets real
> filenames. Omit the /noshell keyword.
>
> regards,
> lajos
>
Also, note than when you remove the /noshell your command becomes more like:
spawn,'ls data/2003????'
Be careful though that the user hasn't alias 'ls' to do something else,
it can sometimes be safer to do:
spawn,'\ls data/2003????'
the '\ls' is a standard unix feature which ignores any aliases. Of
course, some idiot could have replaced their ls binary but that's less
likely than having an alias present. Lots of modern linux distributions
have built in --color etc, I personally have: 'ls -h --color -F'. If
you're going to capture the output via something like:
spawn,'\ls data/2003????',output
then you really don't want all the colour codes in amongst things.
Thanks,
Allan
|
|
|
Re: spawn and 'ls *.out' [message #50282 is a reply to message #50276] |
Tue, 19 September 2006 14:59  |
Foldy Lajos
Messages: 268 Registered: October 2001
|
Senior Member |
|
|
On Tue, 19 Sep 2006, queiny98@yahoo.com wrote:
> Dear IDL experts,
>
> Can I use '*' and '?' in the UNIX commands through 'spawn'?
>
> When I try:
>
>> spawn, ['ls', 'data/2003????'], /noshell
> Cannot access data/2003????: No such file or directory
>
> I have files like '20030101', '20030102', etc. in this directory.
> It seems 'spawn' interpolate '?' directly or literally. How could I let
> IDL know?
>
> Thanks.
>
* and ? are evaluated by the shell. ls (and any other program) gets real
filenames. Omit the /noshell keyword.
regards,
lajos
|
|
|