Question

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

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top