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

Home » Public Forums » archive » Re: 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
Re: Multiple Spawn Commands [message #49292] Fri, 14 July 2006 09:43 Go to next message
Ryan. is currently offline  Ryan.
Messages: 77
Registered: March 2006
Member
Jo,
Thank you for your response, that is going to make my life a lot easier
but i can't seem to get it work properly in a UNIX environment. How do
you write a foreach loop in a UNIX environment in one line? I have
experimented a bit with it but it keeps complaining to me about
misplace brackets, what is the proper syntax?

Thanks again,
Ryan.
Re: Multiple Spawn Commands [message #49293 is a reply to message #49292] Fri, 14 July 2006 09:16 Go to previous messageGo to next message
Jo Klein is currently offline  Jo Klein
Messages: 54
Registered: January 2006
Member
Hi Ryan,
I'm not sure I understand what you're trying to do - if you simply want
multiple commands to be executed in the same UNIX shell, you can simply
separate them with semicolons such as
mystring='ls; echo Hoorah! A listing!'
spawn,mystring
Similarly, in a bash environment, you could do
mystring='foreach f in 1 2 3; do echo $f; done'
and spawn it. I'm sure you can derive the csh syntax from here.
Hope this helps,
Jo
Re: Multiple Spawn Commands [message #49377 is a reply to message #49292] Tue, 18 July 2006 04:04 Go to previous message
Jo Klein is currently offline  Jo Klein
Messages: 54
Registered: January 2006
Member
Hi Ryan,
I notice you've gone for the IDL loop option, which is probably more
portable, so just for the record: This is the way you can do it in a
UNIX environment if you're running bash or sh. I just checked the doc,
csh and tcsh do not allow the use of a semicolon to delimit commands. To
make my one line solution work, you would have to switch to a bash
environment before starting IDL, such as
> bash
> idl
Cheers,
Jo
Re: Multiple Spawn Commands [message #49389 is a reply to message #49292] Fri, 14 July 2006 11:27 Go to previous message
Maarten Sneep is currently offline  Maarten Sneep
Messages: 2
Registered: February 2006
Junior Member
In article <1152895388.545979.198960@75g2000cwc.googlegroups.com>,
"Ryan." <rchughes@brutus.uwaterloo.ca> wrote:

> Jo,
> Thank you for your response, that is going to make my life a lot easier
> but i can't seem to get it work properly in a UNIX environment. How do
> you write a foreach loop in a UNIX environment in one line? I have
> experimented a bit with it but it keeps complaining to me about
> misplace brackets, what is the proper syntax?

What is your shell:
spawn, "echo $SHELL"
should tell. Because of the syntax you use in your original post, I
think you're using a csh derivative. It has been a while, but I think
a foreach loop looks like:

spawn, "foreach i (item1 item2 item3); action $i; end"

An O'Reilly book on shells will help you here, but often it is easier,
and more portable, to perform the action in IDL.

If all fails:
for ii=0,n_elements(files)-1 do $
spawn, "file_dump.ps " + files[ii]

(yeah, I know, lots of overhead, not pretty, but at least it'll work.)

Maarten
--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Tutorial Using idl in java applications???
Next Topic: indexing structure of structures

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

Current Time: Wed Oct 08 13:52:06 PDT 2025

Total time taken to generate the page: 0.00617 seconds