2012-06-22 6 views
5

IDL에 프로그램을 작성하여 명령 줄 인수를 기반으로 산점도를 생성했습니다. 나는 성공적으로이 같은 터미널에서 직접 프로그램을 호출 할 수 있습니다변수가있는 bash의 IDL 프로그램 실행

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

경우 $ *에 입력 한 일부 문자열 리터럴을 참조 문제는 내가 퍼팅, 난 그냥 바로 그 줄을 입력 할 수있을 거라고 생각합니다. 리터럴 대신 변수 이름으로, bash 스크립트로, 그리고 흩어져있는 동안 백만개의 분산 플롯을 생성합니다.

idl: -e option cannot be specified with batch files

그래서 나의 다음 시도가 그때 실행할 것 IDL의 배치 파일에 해당 명령을 작성하려고했다 : 나는 그런 식으로한다면 불행하게도, 나는 오류가 발생합니다.

그 시도는 다음과 같습니다

#!/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을 사용하거나 유효한 IDL 루틴 호출을 구성하는 두 가지 방법이 있습니다. 이 루틴은 모두 사용하여 다음 두 가지 방법 중 하나로 명령 줄에서

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

내가 IDL 모르겠지만, 여기에 도움이 가능성이 배시 스크립트에 대한 수정 사항은 다음과 같습니다

#!/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" 

가 견적 변수가 확장되면

관련 문제