- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 05:55 AM - last edited on тАО06-24-2013 06:46 PM by Maiko-I
тАО05-03-2002 05:55 AM - last edited on тАО06-24-2013 06:46 PM by Maiko-I
hi,
I have two files from which i would like to build a third file-
VGfile:(sample)
VG01 001 009 010 019
VG02 109 110 1A0 1B0
....
syminq.out: (sample)
****
/dev/rdsk/c49t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920
/dev/rdsk/c54t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920
/dev/rdsk/c49t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920
/dev/rdsk/c54t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920
.....
**
Using these two files, i would like to build a file , which will have the corresponding VG appended to every entry in syminq.out file as follows:
---
/dev/rdsk/c49t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920 VG01
/dev/rdsk/c54t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920 VG01
/dev/rdsk/c54t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920 VG01
/dev/rdsk/c49t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920 VG01
----
Any elegant way to do this?
thanks
P.S. This thread has been moved from HP-UX > System Administration to HP-UX > languages - HP Forum Moderator
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:05 AM
тАО05-03-2002 06:05 AM
Re: Script question
34001000 == 001 009 010 019
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:13 AM
тАО05-03-2002 06:13 AM
Re: Script question
1. Read syminq.out using while
2. Take out the first entry and replace rdsk with dsk.
3. Do a pvdisplay on that entry and grep for VG Name and use awk to filter out the vg.
4. Since you are still in the while loop append
vg to the line (or $0).
-Sri
PS: probably you forgot yourself that you developed a helpdesk system.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:16 AM
тАО05-03-2002 06:16 AM
Re: Script question
i.e 34001 34009 etc.
In shell, grep seems the obvious way to go about it. But, once i get the grep results , how do i plug in the VG name for each entry in the last column?
Ok, over to perl procura ;-) This should be a breeze in perl.
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:21 AM
тАО05-03-2002 06:21 AM
Re: Script question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:27 AM
тАО05-03-2002 06:27 AM
Re: Script question
Here is the script for that
$ cat file1
vg01 001 009 010 019
vg02 011 019 011 011
$
$ cat file2
/dev/rdsk/c49t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920
/dev/rdsk/c54t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920
/dev/rdsk/c49t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920
/dev/rdsk/c54t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920
$
$ cat concat.sh
#!/usr/bin/ksh
{
set -x
count=0
while read j
do
count=`expr $count + 1`
done < file2
num=0
while [ ${num} -lt ${count} ]
do
num=`expr $num + 1`
str1=`sed -n "${num}p" file2`
str2=`sed -n "${num}p" file1 | awk '{print $1}'`
echo "${str1} ${str2}" >> file3
done
} 2>/tmp/concat.log
$
$ ./concat.sh
$ cat file3
/dev/rdsk/c49t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920 vg01
/dev/rdsk/c54t0d0 M(8) EMC SYMMETRIX 5567 34001000 15697920 vg02
/dev/rdsk/c49t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920
/dev/rdsk/c54t0d1 M(8) EMC SYMMETRIX 5567 34009000 15697920
Just my two cents.
-Sukant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:28 AM
тАО05-03-2002 06:28 AM
Re: Script question
open(INP,"
chomp;
@ary=split(" ",$_);
$vg=shift(@ary);
foreach $ix (@ary) {
$map{$ix}=$vg;
}
}
close(INP);
open(INP,"
chomp;
($ix)=/ 34(\d\d\d)/;
print $_," ",$map{$ix},"\n";
}
-- Rod Hills
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:42 AM
тАО05-03-2002 06:42 AM
Re: Script question
I did a little something for this exact same thing awhile back. Now I am not a programmer so my script is very 'juvenile'. I had 4 servers attached to 1 EMC Symmetrix - I used their inq utility and wrote my own scripts and had them rcp the result to 1 server where I combined all the files and produced a flat file sorted that I then imported into Excel and dressed up. I am not proficient enough to write the print code to get a good report via HPUX. Also 1 of the servers-I had to adjust my script since it used mass amounts of 'raw' (yes I said raw) volumes...and the inq utility will not show these as used (arghghg!).
Anyway...I wrote these little ditties and I'll be happy to email them to you if you want to take a look.
Mine puts it down to the filesystem (except for the raw devices, I could only get to the vg).
rworkman@wvbep.org
Rgrds,
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:45 AM
тАО05-03-2002 06:45 AM
Re: Script question
The luns in question are not yet assigned to a VG. I want to create a map to make the vg creation process easy. Yeah, i am brain-dead today ;-) BTW,Good to see you back.
Anyway, i came up with a two-script kludge which does what i am looking for:
---
while read -r vg d1 d2 d3 d4
do
grep -e 34$d1 -e 34$d2 -e 34$d3 -e 34$d4 syminq.out >>$vg.map
done
for i in `ls *.map`
do
while read -r d1 d2 d3 d4 d5 d6 d7
do
i1=`echo $i |awk '{FS="."; print $1}'`
echo "$d1 $d2 $d3 $d4 $d5 $d6 $d7 $i1" >>$i.new
done <$i
done
---
This creates a file vgname.map.new for each VG which has the corresponding Lun entries of the inq file appended to the vg name.
Sort of messy, but it deserves some points ;-)
Procura - i hope this explains on what i am looking for.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-03-2002 06:52 AM
тАО05-03-2002 06:52 AM
Solution@ARGV = ("vgfile");
while (<>) {
chomp;
($vg, @ary) = split " ";
@map{@ary} = ($vg) x @ary;
}
@ARGV = ("syminq.out");
while (<>) {
s/( 34(\d\d\d).*)/$1 $map{$2}/;
print;
}