I wrote a program in IDL to generate scatterplots based on command line arguments. I can successfully call the program directly in the terminal as follows:
idl -e "scatterplot_1_2d_file.pro" $ infile $ outfile $ title $ xtitle $ ytitle $ xmin $ xmax $ ymin $ ymax $ timescale
Where $ * refers to some string literals typed. The problem is that I thought I could just type the very string by typing the variable names instead of literals in the bash script, and generate a million scatter plots while I'm at the break. Unfortunately, if I do this, I get an error message:
idl: -e parameter cannot be specified with batch files
So, my next attempt was to try to write these commands to an IDL batch file that I would run.
This attempt is as follows:
#!/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" >> $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 >> $batchfile
done
echo exit >> $batchfile
idl <<EOF
@/path/to/scatterplot_1_2d_file
EOF
rm $batchfile
I don’t know if the bulk of the errors generated by the script are important, so I’ll just post the beginning and I will post the rest later if you need it:
[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 <INT ( 1)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 2)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 3)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 4)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 5)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 6)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 7)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 8)> is out of range.
% Execution halted at: $MAIN$
% Attempt to subscript ARGS with <INT ( 9)> is out of range.
% Execution halted at: $MAIN$
I do not know if I am trying to do something that cannot be done, but it does not look like it. Any tips?
source
share