LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2008, 05:51 AM   #1
rajveervashisth
LQ Newbie
 
Registered: Mar 2008
Posts: 19

Rep: Reputation: 0
Lightbulb Bash script needed with 2 variables for AIX .


Hi ,

I need a bash script which can do following

mkvdev -vdev $i -vadapter vhost2 -dev bd2_app$j

where $i is the hdisk name (variable after running cfgmgr)
and $j is the second variable which is just like a label.

so if there are 5 hdisks .
I require,
a) it should ask me what should be j to start from (ex: 59)
b) it increment j till 64 (for 5 i )

and run following


mkvdev -vdev hdisk23 -vadapter vhost2 -dev bd2_app59
mkvdev -vdev hdisk24 -vadapter vhost2 -dev bd2_app60
mkvdev -vdev hdisk25 -vadapter vhost2 -dev bd2_app61
mkvdev -vdev hdisk26 -vadapter vhost2 -dev bd2_app62
mkvdev -vdev hdisk27 -vadapter vhost2 -dev bd2_app63
 
Old 08-04-2008, 05:55 AM   #2
rajveervashisth
LQ Newbie
 
Registered: Mar 2008
Posts: 19

Original Poster
Rep: Reputation: 0
although I tried doing like this , but it require me to type both the variable to a file under different column

i/p

cat pqr
1 a
2 b
3 c
4 d
5 e

cat sample_twovari
for i in `cat pqr | awk {'print $1'}`
do
j=`grep $i pqr | awk {'print $2'}`
echo " I Love $i and $j"
done

o/p
I Love 1 and a
I Love 2 and b
I Love 3 and c
I Love 4 and d
I Love 5 and e
 
Old 08-04-2008, 07:35 AM   #3
rajveervashisth
LQ Newbie
 
Registered: Mar 2008
Posts: 19

Original Poster
Rep: Reputation: 0
vi req

hdisk23 bd2_app59
hdisk24 bd2_app60

awk '{print "mkvdev -vdev",$1,"-vadapter vhost2 -dev",$2}' req > run

ksh +x run
 
Old 08-05-2008, 12:31 AM   #4
rajveervashisth
LQ Newbie
 
Registered: Mar 2008
Posts: 19

Original Poster
Rep: Reputation: 0
Got the answer:

#Move old files

ND=/home/rajveerv/newdisk.out
mv $ND "$ND".old

NL=/home/rajveerv/newlabel.out
mv $NL "$NL".old


#Getting newly added disk info
grep -Fvf lspv.bef lspv.aft | awk {'print $1'} > $ND


#Getting label info
echo "input the label Name: ex:bd2_app"
read m
echo "input the starting number:"
read i
r=`wc -l $ND | awk {'print $1'}`
j=$i+$r
while (( i<j ));
do
echo "$m$i" >> $NL
(( i = i + 1 ));
done

paste -d' ' $ND $NL > req

awk '{print "Disk Name is: ",$1,"And the Label is :",$2}' req > run
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 11:33 AM
bash script, understanding variables antis Programming 5 11-15-2007 04:27 AM
Directory variables in a bash script madtinkerer Programming 9 12-04-2006 12:30 PM
Bash script environment variables mbjunior99 SUSE / openSUSE 4 12-28-2005 12:40 AM
bash script variables twantrd Programming 7 11-17-2004 02:38 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration