Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
#!/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

I want to create file system on AIX as priyank1, priyank2 and so on...

VG is the volume group name, LP is the logical partition/size of FS, SAP is the name "priyank" and SID is the Directory under /oracle..

Please let me know if any further details needed. Please help the above script is not working...not reading the variable properly while executing the commands.

also i have placed 2 variable together $SAP$NUM , will this be a problem ?

Regards, Priyank

share|improve this question

2 Answers

up vote 0 down vote accepted

/bin/sh on AIX is usually ksh but your syntax on the first line is still wrong as Eric points out. The "do" comes after the first semicolon.

Another point is the read wants all the values on one line. From your post, it looks like you want separate lines for each input value? e.g.

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

The original would be used as:

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
 ...

But you might be wanting to use it as:

script_name
1  # the value for VG on the first run
2  # the value of LP for the first run
....
share|improve this answer
 
Hi /pedz, thanks a lot. your sugesstions worked just perfect. –  Priyank Arora Sep 27 at 13:02

You are using BASH shell semantics in Bourne shell. Either change the first line to:

#!/bin/bash

or change change your while statement to use Bourne syntax.

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

The [[ expression ]] and (( expression )) syntaxes do not exist in Bourne shell (/bin/sh). You will need to refactor the loop counter increment if you keep using Bourne shell.

share|improve this answer
 
thanks Eric, changing it to #!/bin/bash worked. –  Priyank Arora Sep 27 at 13:03
 
"man sh" on AIX provides: The sh command invokes the default shell and uses its syntax and flags. The shell linked to the /usr/bin/sh path is the default shell. The standard configuration of the operating system links the /usr/bin/sh path to the Korn shell. Also, AIX usually does not have /bin/bash. The syntax of [[ and (( for /bin/sh on AIX works unless the user has altered the default settings which is rare. –  pedz Sep 28 at 13:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.