- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Scripting help needed
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
Forums
Discussions
Discussions
Discussions
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
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
02-02-2007 05:37 AM
02-02-2007 05:37 AM
Scripting help needed
In a directory i have the following files. Is there any way which will give me only the vg names out of this. I want to write a script in which i need to put the command so that and export the VGs from the server.
vg_p01_ss01.bcv1.imp.ksh
vg_p01_ss01.imp.ksh
vg_p01_ss02.bcv1.imp.ksh
vg_p01_ss02.imp.ksh
vg_p01_ss03.bcv1.imp.ksh
vg_p01_ss03.imp.ksh
vg_p01_ss04.bcv1.imp.ksh
vg_p01_ss04.imp.ksh
vg_p01_ss05.bcv1.imp.ksh
vg_p01_ss05.imp.ksh
vg_p01_ss06.bcv1.imp.ksh
vg_p01_ss06.imp.ksh
vg_p02_ss01.bcv1.imp.ksh
vg_p02_ss01.imp.ksh
vg_p02_ss02.bcv1.imp.ksh
vg_p02_ss02.imp.ksh
vg_p02_ss03.bcv1.imp.ksh
vg_p02_ss03.imp.ksh
vg_p02_ss04.bcv1.imp.ksh
vg_p02_ss04.imp.ksh
vg_p02_ss05.bcv1.imp.ksh
vg_p02_ss05.imp.ksh
vg_p03_ss01.bcv1.imp.ksh
vg_p03_ss01.imp.ksh
vg_p03_ss02.bcv1.imp.ksh
vg_p03_ss02.imp.ksh
vg_p03_ss03.bcv1.imp.ksh
vg_p03_ss03.imp.ksh
vg_p03_ss04.bcv1.imp.ksh
vg_p03_ss04.imp.ksh
vg_p03_ss05.bcv1.imp.ksh
vg_p03_ss05.imp.ksh
vg_p04_ss01.bcv1.imp.ksh
vg_p04_ss01.imp.ksh
vg_p04_ss02.bcv1.imp.ksh
vg_p04_ss02.imp.ksh
vg_p04_ss03.bcv1.imp.ksh
vg_p04_ss04.bcv1.imp.ksh
vg_p04_ss05.bcv1.imp.ksh
vg_p05_ss01.bcv1.imp.ksh
vg_p05_ss01.imp.ksh
vg_p05_ss02.bcv1.imp.ksh
vg_p05_ss03.bcv1.imp.ksh
vg_p06_ss01.bcv1.imp.ksh
vgp_sam_a2.imp.ksh
Any Suggestion welcome.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 05:48 AM
02-02-2007 05:48 AM
Re: Scripting help needed
I am going to assume that the volume group name ends at the dot character. Hence, I assume that a valid name is "vg_p01_ss01" for example. Then:
# perl -nle 'print $1 if /(vg.*?)\./' file | uniq
...will produce a list of unique names.
You can also do:
# ls | perl -nle 'print $1 if /(vg.*?)\./' | uniq
...to pass your list of files from a directory list output directly.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 05:49 AM
02-02-2007 05:49 AM
Re: Scripting help needed
for file in $(ls);
do echo ${file%%.*};done | sort -u
Is that what you're looking for? If you want the duplicates remove the | sort -u.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 06:22 AM
02-02-2007 06:22 AM
Re: Scripting help needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 11:50 AM
02-02-2007 11:50 AM
Re: Scripting help needed
Amit,
Here is a perl one-liner to get the names:
perl -ne s/\..*$//; print unless $seen{$_}++ tmp.txt
-n : loop throug input, Not printing each $_
-e : program text follows
s/\..*$//; : Find text from first dot to end and Substitue with nothing.
$seen{$_}++ : auto increment associative array element with key "$_" = vg name.
The first increment the value is still false
Any further increment it true = none zero
I think this, as well as the other suggestions solve the immediate question.
However, you should consider NOT using the intermediate file. As any of those suggestions generate a uniq name, just construct the full command and make them do the real tasks right there.
Regards,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 01:52 PM
02-02-2007 01:52 PM
Re: Scripting help needed
Thanks for all thes inputs. I will check these Monday and accordingly assign points -:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2007 03:44 PM
02-02-2007 03:44 PM
Re: Scripting help needed
Go to directory where you have the files and execute the following coomand to fulfill your requirements, you can can any optional arguements to the vgexport
ls -ltr | awk '{print $9}'|cut -d . -f 1 | uniq |xargs vgexport
Happy Scripting
TQ
Perumal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2007 12:03 AM
02-03-2007 12:03 AM
Re: Scripting help needed
I tried ls -ltr | awk '{print $9}'|cut -d . -f 1 | uniq |
I am getting this
vg_p01_ss05
vg_p02_ss01
vg_p02_ss02
vg_p02_ss03
vg_p02_ss04
vg_p02_ss05
vg_p03_ss01
vg_p03_ss02
vg_p03_ss03
vg_p03_ss04
vg_p03_ss05
vg_p01_ss05
vg_p01_ss01
vg_p01_ss02
vg_p01_ss03
vg_p01_ss04
vg_p04_ss01
vg_p05_ss01
vg_p04_ss02
vgp_sam_a2
vg_p03_ss03
vg_p03_ss04
vg_p01_ss06
xpinfo
vg_p04_ss03
vg_p05_ss03
vg_p04_ss05
vg_p04_ss04
vg_p03_ss04
vg_p05_ss02
vg_p03_ss03
vg_p04_ss02
vg_p05_ss01
vg_p03_ss03
vg_p03_ss04
vg_p03_ss05
vg_p05_ss01
vg_p03_ss05
vg_p03_ss04
vg_p05_ss01
vg_p04_ss03
vg_p04_ss04
vg_p05_ss03
vg_p03_ss04
vg_p03_ss05
vg_p04_ss02
mapfile
vg_p03_ss05
vg_p05_ss02
vg_p04_ss05
vg_p05_ss03
vg_p04_ss03
vg_p03_ss03
vg_p04_ss04
vg_p03_ss05
vg_p01_ss05
vg_p02_ss01
vg_p02_ss04
vg_p02_ss02
vg_p03_ss01
vg_p03_ss02
vg_p02_ss03
vg_p02_ss05
vg_p05_ss01
vg_p06_ss01
vg_p01_ss01
vg_p01_ss02
vg_p01_ss03
vg_p01_ss04
vg_p04_ss01
vg_p01_ss06
vg_p06_ss01
vg_p05_ss02
vg_p04_ss04
vg_p04_ss05
vg_p04_ss03
vg_p05_ss02
vg_p05_ss03
vg_p04_ss05
vg_p05_ss03
vg_p04_ss03
vg_p02_ss01
vg_p03_ss05
vg_p02_ss04
vg_p03_ss05
vg_p01_ss04
vg_p03_ss05
vg_p03_ss03
vg_p01_ss05
vg_p01_ss04
vg_p01_ss05
vg_p02_ss04
vg_p03_ss04
vg_p02_ss04
vg_p03_ss04
vg_p01_ss03
vg_p01_ss02
vg_p01_ss03
vg_p03_ss01
vg_p02_ss05
vg_p02_ss02
vg_p01_ss01
vg_p01_ss02
vg_p02_ss03
vg_p02_ss02
vg_p03_ss01
vg_p02_ss05
vg_p01_ss01
vg_p04_ss01
vg_p01_ss06
vg_p05_ss01
vg_p03_ss02
vg_p05_ss01
vg_p04_ss02
Also i tried this for file in $(ls);
> do echo ${file%%.*};done | sort -u
I am getting same result. The bcv part from the VG is missing. What is the way to get that/
Please help me out. I have to do it today.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2007 12:24 AM
02-03-2007 12:24 AM
Re: Scripting help needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2007 12:26 AM
02-03-2007 12:26 AM
Re: Scripting help needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2007 02:11 AM
02-03-2007 02:11 AM
Re: Scripting help needed
Ok:
1- If you are not comfortable scripting, or adapting the suggested solutions, then just take the closest solution and go into an editor and do the thing alright! You could have been done by now.
But scripting is preferable, even if it is more work, because it will get it right, and it will be repeatable.
2- If you want us to help better, then PLEASE be more explicit on what you want.
Input: blah.xxx.blahblah
Output: command blah.xxx yyy xxx ?
Conditions?
3-Google! +bcv +vg +import
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=349968
4- MAN PAGE: vgchid
5 - Uniq only compares ADJACENT lines. So you must pre-sort the file or know for sure it is (still) sorted after the transformations.
6- Try this
ls | -ne s/(bcv\d+)\..*$/$1/; print unless $seen{$_}++"
Hope this helps,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2007 02:15 AM
02-03-2007 02:15 AM
Re: Scripting help needed
Please review the notion of Volume GROUPS.
The system perform better, and be easier to manage if it is set up with multiple PV's in fewer VG's carved out to multiple LV's each.
Regards,
Hein van den Heuvel
HvdH Peformance Consulting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2007 02:20 AM
02-03-2007 02:20 AM
Re: Scripting help needed
It would have be easier, had you defined what constituted a volume group name in the beginning. That said, your data suggests that this will work:
# perl -nle 'print $1 if /(vg.+\.bcv\d)\..*/' file
(or):
# ls /path | perl -nle 'print $1 if /(vg.+\.bcv\d)\..*/'
Now, if you want to perform this extraction and 'vgexport' the volume groups, you could do:
# ls path | perl -nle 'print $1 if /(vg.+\.bcv\d)\..*/' | xargs -n 1 -i vgchange -a n {}
This inactivates the volume groups before their export. Then, follow with:
# ls path | perl -nle 'print $1 if /(vg.+\.bcv\d)\..*/' | xargs -n 1 -i vgexport -v -s -m {}.mapfile {}
This performs the actual 'vgexport' *and* keeps a mapfile of the volume group for reuse.
Regards!
...JRF...