2012-06-22 8 views
5

मैंने कमांड लाइन तर्कों के आधार पर स्कैटर प्लॉट जेनरेट करने के लिए आईडीएल में एक प्रोग्राम लिखा है। मैं सफलतापूर्वक इस तरह टर्मिनल में सीधे कार्यक्रम कॉल कर सकते हैं:चर के साथ बैश से आईडीएल प्रोग्राम चलाना

idl -e "scatterplot_1_2d_file.pro" $infile $outfile $title $xtitle $ytitle $xmin $xmax $ymin $ymax $timescale

कहाँ $ * में टाइप कुछ स्ट्रिंग शाब्दिक का उल्लेख समस्या यह है, मैंने सोचा कि मैं सिर्फ टाइप करने के लिए है कि बहुत लाइन सक्षम होगा, डाल। अक्षरों के स्थान पर परिवर्तनीय नामों में, एक बैश स्क्रिप्ट में, और जब मैं ब्रेक पर हूं तो लाखों स्कैटर प्लॉट उत्पन्न करता हूं।

idl: -e option cannot be specified with batch files

तो मेरा अगला प्रयास एक आईडीएल बैच फ़ाइल है कि मैं तो चलाने चाहते हैं करने के लिए उन आदेशों लिखने का प्रयास किया गया था: दुर्भाग्य से, अगर मैं इसे इस तरह से करते हैं, मैं त्रुटि मिलती है।

कि प्रयास इस तरह दिखता है:

#!/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 #done file                                                 

echo exit >> $batchfile 

idl <<EOF                                                  
@/path/to/scatterplot_1_2d_file                                         
EOF                                                    

rm $batchfile 

मैं नहीं जानता कि यदि त्रुटियों स्क्रिप्ट उत्पन्न करता है कि प्रासंगिक हैं, तो मैं बस शुरुआत पोस्ट करेंगे और मैं बाकी बाद में पोस्ट करेंगे के थोक यदि आपको आवश्यकता:

[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$   

मैं अगर मैं सिर्फ कुछ है कि नहीं किया जा सकता करने के लिए कोशिश कर रहा हूँ पता नहीं है, लेकिन यह ऐसा नहीं लगता है। कोई सलाह?

+1

आप होगा सब [हवाले से] (http ठीक करने के लिए: // mywiki। इससे पहले कि हम विशिष्ट सलाह दे सकें, wooledge.org/Quotes) त्रुटियों, और [फाइलनामों के हैंडलिंग] (http://mywiki.wooledge.org/ParsingLs) को सही करें। यदि आप उसके बाद फंस गए हैं, तो नई त्रुटि पोस्ट करें। – ormaaj

उत्तर

5

इस बारे में जाने के दो तरीके हैं: COMMAND_LINE_ARGS का उपयोग करके या एक वैध आईडीएल रूटीन कॉल का निर्माण। यह दिनचर्या दोनों का उपयोग करता है:

pro test, other_args 
    compile_opt strictarr 

    args = command_line_args(count=nargs) 

    help, nargs 
    if (nargs gt 0L) then print, args 

    help, other_args 
    if (n_elements(other_args) gt 0L) then print, other_args 
end 

निम्नलिखित दो तरीकों में से किसी कमांड लाइन से कॉल:

Desktop$ idl -e "test" -args $MODE 
IDL Version 8.2, Mac OS X (darwin x86_64 m64). (c) 2012, Exelis Visual Information Solutions, Inc. 
Installation number: 216855. 
Licensed for use by: Tech-X Corporation 

% Compiled module: TEST. 
NARGS   LONG  =   1 
test 
OTHER_ARGS  UNDEFINED = <Undefined> 
Desktop$ idl -e "test, '$MODE'" 
IDL Version 8.2, Mac OS X (darwin x86_64 m64). (c) 2012, Exelis Visual Information Solutions, Inc. 
Installation number: 216855. 
Licensed for use by: Tech-X Corporation 

% Compiled module: TEST. 
NARGS   LONG  =   0 
OTHER_ARGS  STRING = 'test' 
test 
4

मैं आईडीएल पता नहीं है, लेकिन यहाँ कि मदद करने के लिए की संभावना है अपने बैश स्क्रिप्ट के लिए फिक्स कर रहे हैं:

#!/bin/bash 

indir=/path/to/indir/ 
outdir=/path/to/outdir/ 

# (commented out) files=`ls $indir` # no, just no 
batchfile=/path/to/tempbatchfile.pro 

echo ".r /path/to/scatterplot_1_2d_file.pro" > "$batchfile" # overwrite the file on the first write, put everything inside the quotes 

for file in "$indir/"* 
    do 
    name=${file%\.*} 
    echo "scatterplot_1_2d_file $indir$name.txt $outdir$name.jpg $name Gauge Precipitation (mm) NMQ Precipitation (mm) * * * * 2" # quote the whole thing once, it's simpler and echo doesn't do anything differently 
done >> "$batchfile" # do all the output from the loop 
echo exit >> "$batchfile" 

# *** where does idl learn the location of "$batchfile"? *** 
idl <<EOF                                                  
@/path/to/scatterplot_1_2d_file                                         
EOF                                                    

rm "$batchfile" 

अपने आदेश पंक्ति संस्करण को ठीक करने के लिए, उपयोग के हवाले से:

idl -e "scatterplot_1_2d_file.pro" "$infile" "$outfile" "$title" "$xtitle" "$ytitle" "$xmin" "$xmax" "$ymin" "$ymax" "$timescale" 

हमेशा जब वे विस्तारित होते हैं तो उद्धरण चर।

संबंधित मुद्दे