Help needed on calling an IDL procedure from the Linux command line [message #45268] |
Wed, 24 August 2005 13:59  |
Sanjay[1]
Messages: 1 Registered: August 2005
|
Junior Member |
|
|
Hello all,
I have a question regarding calling IDL from a Linux command line. By
testing this out directly, I know that an IDL code can indeed be called
from the command line, e.g.:
$ idl test.pro
However, my limited experience indicates that this is not entirely
successful if "test" is a procedure, i.e. if it starts with the line:
PRO test, input
In this case I get the following error: "Programs can't be compiled
from a single statement mode". However, it seems not to matter too much
(at least for my purposes), since IDL keeps going onto the next line
anyway. But I don't know how to send the necessary variable "input" in
this case.
So I was wondering: is it possible to pass input variables via a
command line call? Can these be provided directly, or via an input
file? I contacted David Fanning, and he suggested that this group would
be a good source of information on this topic. Any help or information
that you have on this would be greatly appreciated.
Take care,
Sanjay
|
|
|
|
Re: Help needed on calling an IDL procedure from the Linux command line [message #45340 is a reply to message #45268] |
Sat, 27 August 2005 16:25  |
Michael Wallace
Messages: 409 Registered: December 2003
|
Senior Member |
|
|
> So I was wondering: is it possible to pass input variables via a
> command line call? Can these be provided directly, or via an input
> file? I contacted David Fanning, and he suggested that this group would
> be a good source of information on this topic. Any help or information
> that you have on this would be greatly appreciated.
The new IDL 6.2 includes support for command line arguments. You can
specify command line arguments with either the -arg or -args options.
For example:
$ idl test.pro -quiet -args arg1 arg2 arg3
Notice that the file test.pro must be a batch file rather than a
procedure or function. If it's not a batch file, you will get the error
message about programs not being able to be compiled in single statement
mode. Here are the contents of a very simple test.pro:
args = command_line_args()
print, n_elements(args)
print, args
And here's what I get when running it:
$ idl test.pro -quiet -args arg1 arg2 arg3
3
arg1 arg2 arg3
Typically, I will keep the batch file pretty small and use it only parse
the command line arguments. I then call the procedure or function that
does the real work. I split things up this so that I can call my core
code either from the command line or from another routine. My batch
programs usually look something like:
args = command_line_args()
; check args and set input and keyword values
really_nifty_idl_code(input1, input2, keyword = keyword1)
-Mike
|
|
|