2013-09-23 33 views
1
#!/bin/sh 

echo "VG: " 
read VG 
echo "LP: " 
read LP 
echo "SAP: " 
read SAP 
echo "NUM: " 
read NUM 
echo "SID: " 
read SID 


while [[ $NUM -lt 2 ]]; read VG LP SAP NUM SID ; do 

mklv -y $SAP$NUM -t jfs2 -e x $VG $LP; 

crfs -v jfs2 -d /dev/$SAP$NUM -m /oracle/$SID/$SAP$NUM -A yes -p rw -a log=INLINE -a options=cio; 

NUM=$((NUM+1)) OR ((NUM++)) 

done 

我想在AIX上創建文件系統priyank1,priyank2等等...文件系統創建腳本while循環

VG是卷組的名稱,LP爲邏輯分區/ FS的大小,SAP的名稱是「priyank」,SID是/ oracle下的目錄..

請讓我知道是否需要進一步的細節。 請幫助上述腳本無法正常工作......在執行命令時沒有正確讀取變量。

此外,我已將2個變量放在一起$ SAP $ NUM,這會是一個問題嗎?

問候, Priyank

回答

0

AIX上的/ bin/sh通常是ksh,但是您的語法在第一行仍然是錯誤的,正如Eric所指出的那樣。 「do」是在第一個分號後出現的。

另一點是閱讀需要在一行上的所有值。從你的文章看來,你需要爲每個輸入值分隔行嗎?例如

while [[ $NUM -lt 2 ]] ; do 
    read VG 
    read LP 
    read SAP 
    read NUM 
    read SID 
    . 
    . 
    . 
done 

最初將用作:

script_name 
1 2 3 4 5 # would read all five values for the first run 
6 7 8 9 10 # a new set of five values for the second run 
... 

但是,你可能會想使用它:

script_name 
1 # the value for VG on the first run 
2 # the value of LP for the first run 
.... 
+0

Hi/pedz,非常感謝,你的sugesstions工作得很完美。 –

0

你正在使用bash外殼語義的Bourne shell。要麼改變第一行:

#!/bin/bash 

或改變而改變你的while語句中使用伯恩語法。

while [ $NUM -lt 2 ]; do 
    read VG LP SAP NUM SID 
    mklv -y $SAP$NUM -t jfs2 -e x $VG $LP 
    . 
    . 
    . 
    done 

[[ expression ]]((expression))語法不Bourne shell的(/ bin/sh的)存在。如果繼續使用Bourne shell,則需要重構循環計數器增量。

+0

感謝埃裏克,將其更改爲#/斌/慶典工作。 –

+0

AIX上的「man sh」提供了:sh命令調用缺省shell並使用其語法和標誌。鏈接到/ usr/bin/sh路徑的外殼是默認外殼。操作系統的標準配置將/ usr/bin/sh路徑鏈接到Korn shell。另外,AIX通常沒有/ bin/bash。 [[和((for AIX上的/ bin/sh)的語法是有效的,除非用戶改變了很少的默認設置 – pedz