title: Running IDL program from bash with variables
body: <p>I've written a program in IDL to generate scatter plots based on command line arguments.  I can successfully call the program directly in the terminal like this:</p>
  
  <blockquote>
    <p>idl -e "scatterplot_1_2d_file.pro" $infile $outfile $title $xtitle $ytitle $xmin $xmax $ymin $ymax $timescale</p>
  </blockquote>
  
  <p>Where $* refer to some string literals typed in.  The problem is, I thought I'd be able to just type that very line, putting in variable names in place of the literals, into a bash script, and generate a million scatter plots while I'm on break.  Unfortunately, if I do it that way, I get the error:</p>
  
  <blockquote>
    <p>idl: -e option cannot be specified with batch files</p>
  </blockquote>
  
  <p>So my next attempt was to try writing those commands to an IDL batch file that I'd then run.</p>
  
  <p>That attempt looks like this:</p>
  
  <pre><code>#!/bin/bash
  
  indir=/path/to/indir/
  outdir=/path/to/outdir/
  
  files=`ls $indir`
  batchfile=/path/to/tempbatchfile.pro
  
  echo .r "/path/to/scatterplot_1_2d_file.pro" &gt;&gt; $batchfile
  
  for file in $files
    do
    name=${file%\.*}
    echo scatterplot_1_2d_file $indir$name.txt $outdir$name.jpg $name "Gauge Precipitation (mm)" "NMQ Precipitation (mm)" "*" "*" "*" "*" 2 &gt;&gt; $batchfile
  done #done file                                                                                                                                                                                                
  
  echo exit &gt;&gt; $batchfile
  
  idl &lt;&lt;EOF                                                                                                                                                                                                      
  @/path/to/scatterplot_1_2d_file                                                                                                                                                                  
  EOF                                                                                                                                                                                                            
  
  rm $batchfile
  </code></pre>
  
  <p>I don't know if the bulk of the errors that script generates are relevant, so I'll just post the start and I'll post the rest later if you need it:</p>
  
  <pre><code>[foo]$ bash script_thing.sh
  IDL Version 6.3 (linux x86 m32). (c) 2006, Research Systems, Inc.
  Installation number: 91418.
  Licensed for personal use by XXXXXXXXX only.
  All other use is strictly prohibited.
  
  
  PRO scatterplot_1_2d_file
                           ^
  % Programs can't be compiled from single statement mode.
    At: /path/to/scatterplot_1_2d_file.pro, Line 1
  % Attempt to subscript ARGS with &lt;INT      (       1)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       2)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       3)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       4)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       5)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       6)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       7)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       8)&gt; is out of range.
  % Execution halted at: $MAIN$          
  % Attempt to subscript ARGS with &lt;INT      (       9)&gt; is out of range.
  % Execution halted at: $MAIN$          
  </code></pre>
  
  <p>I don't know if I'm just trying to do something that can't be done, but it doesn't SEEM like it.  Any advice?</p>