comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Multiple Spawn Commands
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Multiple Spawn Commands [message #49294] Fri, 14 July 2006 08:33 Go to next message
Ryan. is currently offline  Ryan.
Messages: 77
Registered: March 2006
Member
Dear IDL Gurus,

Is it possible to issue multiple Spawn commands in Unix IDL without
closing the shell? What I want to do is issue a very simple foreach
loop but i cannot call spawn long enough to input all the commands. I
think i might have to use the Unit keyword of spawn but i'm not sure
how it works. Due to the simplicity of what I want to do I might be
able to do it in fewer commands in Unix but I don't have enough
experience in Unix to know how. Any help would be greatly appreciated.
I want the following commands issued in Unix:

change to desired directory
foreach i ( file1 file2 file3 ... )
...file_dump.pl -$i ...
end

To do this I have the following:
spawn, foreachcommand
spawn, filedumpcommand
spawn, endcommand

but this obviously does not work.

Thanks,
Ryan.
Re: Multiple Spawn Commands [message #49351 is a reply to message #49294] Wed, 19 July 2006 23:59 Go to previous messageGo to next message
peter.albert@gmx.de is currently offline  peter.albert@gmx.de
Messages: 108
Registered: July 2005
Senior Member
The one-line-limitation can be avoided if you put all your commands in
an _executable_ batch file and call this file using SPWAN.


Regards,

Peter

tianyf@gmail.com schrieb:

> It seems that IDL SPAWN evokes a new SHELL and only executes one line
> of comand each time, even when you write all the commands to a temp
> batch file and execute it. You can put all the commands in one line
> (seperated by &&) and execute it. Also, maybe you can use IDL's CD
> procedure to change the working directory.
>
Re: Multiple Spawn Commands [message #49365 is a reply to message #49294] Wed, 19 July 2006 04:40 Go to previous messageGo to next message
enod is currently offline  enod
Messages: 41
Registered: November 2004
Member
It seems that IDL SPAWN evokes a new SHELL and only executes one line
of comand each time, even when you write all the commands to a temp
batch file and execute it. You can put all the commands in one line
(seperated by &&) and execute it. Also, maybe you can use IDL's CD
procedure to change the working directory.

Tian

Ryan. wrote:
> Dear IDL Gurus,
>
> Is it possible to issue multiple Spawn commands in Unix IDL without
> closing the shell? What I want to do is issue a very simple foreach
> loop but i cannot call spawn long enough to input all the commands. I
> think i might have to use the Unit keyword of spawn but i'm not sure
> how it works. Due to the simplicity of what I want to do I might be
> able to do it in fewer commands in Unix but I don't have enough
> experience in Unix to know how. Any help would be greatly appreciated.
> I want the following commands issued in Unix:
>
> change to desired directory
> foreach i ( file1 file2 file3 ... )
> ...file_dump.pl -$i ...
> end
>
> To do this I have the following:
> spawn, foreachcommand
> spawn, filedumpcommand
> spawn, endcommand
>
> but this obviously does not work.
>
> Thanks,
> Ryan.
Re: Multiple Spawn Commands [message #49387 is a reply to message #49294] Sat, 15 July 2006 07:22 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Ryan." <rchughes@brutus.uwaterloo.ca> writes:
> Dear IDL Gurus,
>
> Is it possible to issue multiple Spawn commands in Unix IDL without
> closing the shell? What I want to do is issue a very simple foreach
> loop but i cannot call spawn long enough to input all the commands. I
> think i might have to use the Unit keyword of spawn but i'm not sure
> how it works. Due to the simplicity of what I want to do I might be
> able to do it in fewer commands in Unix but I don't have enough
> experience in Unix to know how. Any help would be greatly appreciated.

I agree with you that this can't be done with semicolons as the other
posters suggested.

> I want the following commands issued in Unix:
> change to desired directory
> foreach i ( file1 file2 file3 ... )
> ...file_dump.pl -$i ...
> end
>
> To do this I have the following:
> spawn, foreachcommand
> spawn, filedumpcommand
> spawn, endcommand

I have to ask, why are you trying to directly transliterate a c-shell
script? You're in IDL, why not use it?

files = ['file1', 'file2', 'file3', '...']
for i = 0, n_elements(files)-1 do begin
cmd = string(files[i], format='("...file_dump.pl -",A0," ... "))
spawn, cmd
end

Or, you could make a single shell script with all the commands you
want to run, give the file executable permissions, and then run it
with a single command from IDL.

Good luck!
Criag


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Multiple Spawn Commands [message #49388 is a reply to message #49294] Fri, 14 July 2006 11:56 Go to previous messageGo to next message
Ryan. is currently offline  Ryan.
Messages: 77
Registered: March 2006
Member
Thanks Maarten.

I've talked to my co-worker who knows more about this than I do and he
said it is not possible with the shell that I am using. It is a
modified csh shell. I've decided that i'm going to do the looping in
IDL and spawn each statement like you suggested.

Ryan.
Re: Multiple Spawn Commands [message #49434 is a reply to message #49351] Fri, 21 July 2006 03:55 Go to previous message
enod is currently offline  enod
Messages: 41
Registered: November 2004
Member
Yeah. This is right, both for Windows (.bat) and Linux (e.g. a C Shell
script). I am sorry that there was a error in my previous post. I might
have confused IDL with Java.

Thanks.

Cheers,
Tian


Peter Albert wrote:
> The one-line-limitation can be avoided if you put all your commands in
> an _executable_ batch file and call this file using SPWAN.
>
>
> Regards,
>
> Peter
>
> tianyf@gmail.com schrieb:
>
>> It seems that IDL SPAWN evokes a new SHELL and only executes one line
>> of comand each time, even when you write all the commands to a temp
>> batch file and execute it. You can put all the commands in one line
>> (seperated by &&) and execute it. Also, maybe you can use IDL's CD
>> procedure to change the working directory.
>>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Multiple instances of usersym in legend
Next Topic: LINUX IDL Install Help

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:12:20 PDT 2025

Total time taken to generate the page: 0.00733 seconds