#!/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等等.
VG是卷组名称,LP是FS的逻辑分区/大小,SAP是"priyank“,SID是/oracle下的目录。
如果需要更多的细节,请告诉我。请帮助上面的脚本不是working...not在执行命令时正确读取变量。
另外,我把两个变量放在一起$SAP$NUM,这会是一个问题吗?
你好,Priyank
发布于 2013-09-24 13:14:59
AIX上的/bin/sh通常是ksh,但是正如Eric指出的,第一行的语法仍然是错误的。"do“出现在第一个分号之后。
另一点是,read需要一行中的所有值。从您的帖子来看,您想要为每个输入值分别列出行吗?例如:
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
....发布于 2013-09-23 23:37:23
在Bourne中使用BASH语义。要么将第一行更改为:
#!/bin/bash或者更改您的while语句以使用Bourne语法。
while [ $NUM -lt 2 ]; do
read VG LP SAP NUM SID
mklv -y $SAP$NUM -t jfs2 -e x $VG $LP
.
.
.
doneBourne (/bin/sh)中不存在[[ expression ]]和(( expression ))语法。如果继续使用Bourne,则需要重构循环计数器增量。
https://stackoverflow.com/questions/18968928
复制相似问题