X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 23 Aug 2024 11:49 AM by  Ben Castellani
Executing IDL program from shell
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

dnantonio



New Member


Posts:1
New Member


--
06 Mar 2018 05:48 AM
    Hi,

    I am new to this forum, so I apologize if my post is not correctly formatted, as I don't understand how to wrap lines.
    I am trying to set up a shell script to execute an IDL program, but I fail to see what is the correct syntax to do so.
    Suppose I have the following simple program

    pro idl_dummy
    print, 'It runs'
    end

    saved in a file named idl_dummy.pro, which I want to execute from the command line. I have tried two methods

    1. If I use the statement

    idl -e idl_dummy.pro

    then I get a syntax error:

    idl_dummy.pro
    ^
    % Syntax error.

    2. If I use the statement

    idl idl_dummy,pro

    Then the I get the following message

    pro idl_dummy
    ^
    % Programs can't be compiled from single statement mode.
    At: /full/path/to/idl_dummy.pro, Line 1
    It runs

    end
    ^
    % Syntax error.
    At:/full/path/to/idl_dummy.pro, Line 5

    What is, then, the correct way to run a program like that?

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    08 Mar 2018 11:07 AM
    You will want to use this statement to run a single-line command from IDL in a shell script.

    idl -e "idl_dummy"

    You are essentially compiling and executing a single line IDL command contained in the quotes. In this case, calling the procedure "idl_dummy". Including the PRO at the end will create a syntax error, as you found out.

    Note: You will need to be careful that idl_dummy.pro is in your Command Line IDL path.

    dnantonio



    New Member


    Posts:1
    New Member


    --
    09 Mar 2018 06:54 AM
    Thank you for your reply. Actually, your suggestion works indeed if the idl_dummy.pro is in my current working directory (i.e. if, prior to calling IDL, I first 'cd' to that directory using the shell). But is there a way to run an IDL program from the shell independently of where its source code is located, that is, just giving IDL its absolute path? For example, if this simple program was a Python program, I could just run

    python /full/path/to/python_dummy.py

    and it would work. Is it then not possible to do the same in IDL?

    Ben Castellani



    Basic Member


    Posts:130
    Basic Member


    --
    23 Aug 2024 11:49 AM
    That isn't possible to do like that. You just need to make sure the PRO file is on your IDL search path first. One way you can do that is by defining the IDL_PATH environment variable.

    For example:

    export IDL_PATH=':+/directory/containing/programs
    idl -e 'idl_dummy"
    You are not authorized to post a reply.