HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Scripting
Operating System - HP-UX
1832651
Members
2769
Online
110043
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
07-26-2007 04:28 AM
07-26-2007 04:28 AM
# This script creates MAP files of VM and copies them to VMHOST
# Set up environment
VGEXP=/usr/sbin
MAPFILE=/home/sysadmin/vmmapfiles
MAPFILE1=/home/sysadmin/vgmaps/
#`hpvmstatus |grep HPUX|grep On|awk '{print $1}'`
# DEV1
echo "Creating DEV1 Map File"
for vg in `remsh dev1 -l root $VGEXP/vgdisplay | grep "VG N" | awk '
{print $NF}'`
do
remsh dev1 -l root $VGEXP/vgexport -v -p -m /$MAPFILE/${vg##*/}.map
${vg}
rcp dev1:$MAPFILE/vg*.map $MAPFILE1/dev1/
done
# DEV2
echo "Creating DEV2 Map File"
for vg in `remsh dev2 -l root $VGEXP/vgdisplay | grep "VG N" | awk '
{print $NF}'`
do
remsh dev2 -l root $VGEXP/vgexport -v -p -m /$MAPFILE/${vg##*/}.map
${vg}
rcp dev2:$MAPFILE/vg*.map $MAPFILE1/dev2/
done
To start with, ignore HPVMSTATUS (hashed out any way)
This script does rlogin from VMHOST server to DEV boxes (Integrity Virtual machine guests),gets the list on the Volume group name and then creates a map file using vgexport and copies the map file to VMHOST server from the dev boxes.
The script has worked fine but it is not dynamic ie. If we add or remove any DEV boxes( we have 7 at present – the script only shows 2 DEV boxes) I need to update the script so I wanted this script to be more dynamic ie.the HPVMSTATUS command above gives the output of all the active DEV boxes and I want to use this command with my script but will need some help in using this within my existing script.
# Set up environment
VGEXP=/usr/sbin
MAPFILE=/home/sysadmin/vmmapfiles
MAPFILE1=/home/sysadmin/vgmaps/
#`hpvmstatus |grep HPUX|grep On|awk '{print $1}'`
# DEV1
echo "Creating DEV1 Map File"
for vg in `remsh dev1 -l root $VGEXP/vgdisplay | grep "VG N" | awk '
{print $NF}'`
do
remsh dev1 -l root $VGEXP/vgexport -v -p -m /$MAPFILE/${vg##*/}.map
${vg}
rcp dev1:$MAPFILE/vg*.map $MAPFILE1/dev1/
done
# DEV2
echo "Creating DEV2 Map File"
for vg in `remsh dev2 -l root $VGEXP/vgdisplay | grep "VG N" | awk '
{print $NF}'`
do
remsh dev2 -l root $VGEXP/vgexport -v -p -m /$MAPFILE/${vg##*/}.map
${vg}
rcp dev2:$MAPFILE/vg*.map $MAPFILE1/dev2/
done
To start with, ignore HPVMSTATUS (hashed out any way)
This script does rlogin from VMHOST server to DEV boxes (Integrity Virtual machine guests),gets the list on the Volume group name and then creates a map file using vgexport and copies the map file to VMHOST server from the dev boxes.
The script has worked fine but it is not dynamic ie. If we add or remove any DEV boxes( we have 7 at present – the script only shows 2 DEV boxes) I need to update the script so I wanted this script to be more dynamic ie.the HPVMSTATUS command above gives the output of all the active DEV boxes and I want to use this command with my script but will need some help in using this within my existing script.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2007 04:37 AM
07-26-2007 04:37 AM
Re: Shell Scripting
I guess maybe you're asking how to make the script more dynamic in terms of the hosts it will query? A technique I use is to add a comment flag in the /etc/hosts file for all the unix boxes I want a particular script to run against, then use a for loop to cycle through them, like this:
HOSTLIST=`cat /etc/hosts |grep "#unixhost" |awk -F# '{ print $3 }'`
for SERVER in $HOSTLIST
do
The /etc/hosts entry looks like this:
99.99.99.250 sire sire.holstein.com #unixhost#sire
Pete
Pete
HOSTLIST=`cat /etc/hosts |grep "#unixhost" |awk -F# '{ print $3 }'`
for SERVER in $HOSTLIST
do
The /etc/hosts entry looks like this:
99.99.99.250 sire sire.holstein.com #unixhost#sire
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2007 04:56 AM
07-26-2007 04:56 AM
Re: Shell Scripting
Hi:
> HPVMSTATUS command above gives the output of all the active DEV boxes and I want to use this command with my script but will need some help in using this within my existing script.
Then your script can be reduced to something link this (untested):
#!/usr/bin/sh
VGEXP=/usr/sbin
MAPFILE=/home/sysadmin/vmmapfiles
MAPFILE1=/home/sysadmin/vgmaps/
LIST=`hpvmstatus |grep HPUX|grep On|awk '{print $1}'`
for DEV in ${LIST}
do
echo "Creating ${DEV} Map File"
for vg in `remsh ${DEV} -l root ${VGEXP}/vgdisplay | grep "VG N" | \
awk '{print $NF}'`
do
remsh ${DEV} -l root ${VGEXP}/vgexport -v -p -m /$MAPFILE/${vg##*/}.map ${vg
}
rcp ${DEV}:$MAPFILE/vg*.map ${MAPFILE}/${DEV}
done
...NOW: You can eliminate using 'grep' pipes with 'awk'. 'awk' can pattern match and extract. Re-factor your matching to be included in your 'awk' for efficiency!
Regards!
...JRF...
> HPVMSTATUS command above gives the output of all the active DEV boxes and I want to use this command with my script but will need some help in using this within my existing script.
Then your script can be reduced to something link this (untested):
#!/usr/bin/sh
VGEXP=/usr/sbin
MAPFILE=/home/sysadmin/vmmapfiles
MAPFILE1=/home/sysadmin/vgmaps/
LIST=`hpvmstatus |grep HPUX|grep On|awk '{print $1}'`
for DEV in ${LIST}
do
echo "Creating ${DEV} Map File"
for vg in `remsh ${DEV} -l root ${VGEXP}/vgdisplay | grep "VG N" | \
awk '{print $NF}'`
do
remsh ${DEV} -l root ${VGEXP}/vgexport -v -p -m /$MAPFILE/${vg##*/}.map ${vg
}
rcp ${DEV}:$MAPFILE/vg*.map ${MAPFILE}/${DEV}
done
...NOW: You can eliminate using 'grep' pipes with 'awk'. 'awk' can pattern match and extract. Re-factor your matching to be included in your 'awk' for efficiency!
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2007 05:39 AM
07-26-2007 05:39 AM
Solution
Hi (again):
Oops! If dropped a 'done':
#!/usr/bin/sh
VGEXP=/usr/sbin
MAPFILE=/home/sysadmin/vmmapfiles
LIST=`hpvmstatus |grep HPUX|grep On|awk '{print $1}'`
for DEV in ${LIST}
do
echo "Creating ${DEV} Map File"
for vg in `remsh ${DEV} -l root ${VGEXP}/vgdisplay \
| awk '/^VG Name/ {print $NF}'`
do
remsh ${DEV} -l root ${VGEXP}/vgexport -v -p -m /$MAPFILE/${vg##*/}.map ${vg}
rcp ${DEV}:${MAPFILE}/vg*.map ${MAPFILE}/${DEV}
done
done
exit 0
...Notice that I eliminated a 'grep|awk' pipe that captures the VG Name. Since I don't have a VM setup, I can't run 'hpvmstatus' to see its output and refactor it too.
Regards!
...JRF...
Oops! If dropped a 'done':
#!/usr/bin/sh
VGEXP=/usr/sbin
MAPFILE=/home/sysadmin/vmmapfiles
LIST=`hpvmstatus |grep HPUX|grep On|awk '{print $1}'`
for DEV in ${LIST}
do
echo "Creating ${DEV} Map File"
for vg in `remsh ${DEV} -l root ${VGEXP}/vgdisplay \
| awk '/^VG Name/ {print $NF}'`
do
remsh ${DEV} -l root ${VGEXP}/vgexport -v -p -m /$MAPFILE/${vg##*/}.map ${vg}
rcp ${DEV}:${MAPFILE}/vg*.map ${MAPFILE}/${DEV}
done
done
exit 0
...Notice that I eliminated a 'grep|awk' pipe that captures the VG Name. Since I don't have a VM setup, I can't run 'hpvmstatus' to see its output and refactor it too.
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP