0

I am trying to start an IDL programme from the Windows command line. Lets say I have the following programme:

PRO hello  
print, "Hello, I am a IDL script!"  
a=bytarr(100,200)  
outname='g:\testimage.tif'  
WRITE_TIFF, outname, a  
END   

I want to execute this programme using IDL -e .RUN from the command line as following:

C:\Users\lein_pa>idl -e ".RUN G:/05_Software/01_IDL/IDLWorkspace/Default/hello.pro"  
IDL Version 8.2, Microsoft Windows (Win32 x86_64 m64). (c) 2012, Exelis Visual Information Solutions, Inc.  
Installation number: xxxxx.  
Licensed for use by: xxx  

% Compiled module:HELLO.  
C:\Users\lein_pa> 

As you can see HELLO.pro will be compiled, but no message "Hello, I am a IDL script!" appears on the shell and also testimage.tif is not written to the disk. When I start this programme from the IDL IDE everything works fine.

Can please someone help me? What am I doing wrong?

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
KingLui81
  • 53
  • 1
  • 7

1 Answers1

1

You could keep the file with the same name, but change it to a batch-like file by commenting out the PRO hello and END since everything in your routine could just as easily be run from the command line.

Then to start everything, try:

C:\Users\lein_pa>idl -e G:/05_Software/01_IDL/IDLWorkspace/Default/hello.pro

On unix-based systems, this would start IDL and immediately run the batch file hello.pro. If you need the double quotes for a Windows based machine, then add those accordingly.

Keep in mind, if you make this routine more complicated but keep it as a batch file, then be careful with loops as you will need to use $ and & $ at the end of lines to include them in loops. I am quite certain that one could run actual programs/functions on startup, but it's just as easy to type in the function name after startup if it's necessary. Typically one wants to use a startup batch routine to set personal preferences/defaults that you wish to use or commonly use when in IDL.

honeste_vivere
  • 308
  • 5
  • 11
  • That's a good idea, thanks a lot. But hello.pro of course is only a simple example programme. I want to call already exisiting very complex programmes from the command line, that cannot be changed in their structure or codings. – KingLui81 Sep 12 '14 at 06:47
  • Do you mean that you want to have a number of routines run when you first start IDL or that you want to be able to run IDL routines from outside of IDL on a command line? The former is very easy, just call them from inside a simple bash routine like your hello.pro or even from the command line once in IDL. The latter is possible, but may be a little trickier. Have you looked at: [Command-line Options for IDL Startup](http://www.exelisvis.com/docs/command_line_options_for.html) or [Executing SAVE Files](http://www.exelisvis.com/docs/Executing_SAVE_Files.html) to see if those options work? – honeste_vivere Sep 12 '14 at 12:49
  • Thanks for the links - they helped me to figure out the mistake! I realized that the problem was a small difference in the idl call. While unix based systems work with idl, windows virtual machines work with idlrt to run programmes from the command line. – KingLui81 Sep 22 '14 at 16:47