- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- OK...I need some shell script help..
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
тАО02-26-2001 01:25 PM
тАО02-26-2001 01:25 PM
Take a look at the attached file that is giving me a headache. This is what I've created for doing disk mapping on multiple systems. I did it on 4 servers attached to our EMC disk array..
Each record can have between 3-5 fields (depending on if it's attached to lvol/filesystem or not)
What I am trying to do is get the alternate link (second line of same value as $1) to also print what is reported in the primary disk/lvol/file_sys line.
AND then I want to print a fairly clean report with a space in between different values of $1. Nothing fancy.
This is that disk mapping program I have been working on....and I'm down to this...
..ps..can you tell I am NOT a programmer ! Everytime I try to printf...it blows up because the first line does not have a value for $4 or $5 ... arghghgh !! I've been doing this in Posix Shell. My code is sloppy, but it got me to here..any Help would be appreciated !!
$1 = EMC info
$2 = hostname
$3 = disk addr info
$4 = /dev/vg/lvol
$5 = file_system
Thanks,
Rita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 01:46 PM
тАО02-26-2001 01:46 PM
Re: OK...I need some shell script help..
How about sorting your file on first & fourth field and then applying your logic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 01:54 PM
тАО02-26-2001 01:54 PM
Re: OK...I need some shell script help..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 02:10 PM
тАО02-26-2001 02:10 PM
Re: OK...I need some shell script help..
I'd love to help you, but it would be easier if you submit your script!
Bye,
Rik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 04:10 PM
тАО02-26-2001 04:10 PM
Re: OK...I need some shell script help..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 05:52 PM
тАО02-26-2001 05:52 PM
Re: OK...I need some shell script help..
awk '{if(NF==5){printf("\n%25s %10s - %s, Alt: %s\n",$4,$5,prev3,$3)}prev1=$1;prev3=$3}' name_of_your_file
Maybe you could post what you want the output to say and look like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 06:27 PM
тАО02-26-2001 06:27 PM
Solution---
#!/usr/bin/sh
# Usage: cat somefile | parm5
# Output is always 5 values
# To remove the leading : use this:
# echo ${SN#:} ${HN#:} $DEV ${LVOL:-" "} ${MNT:-" "}
while read SN HN DEV LVOL MNT
do
echo $SN $HN $DEV ${LVOL:-" "} ${MNT:-" "}
done
---
The key is using shell parameter expansion. If LVOL or MNT are null or undefined, the result will be " " (or whatever you'd like). To use this script:
cat InputFile | this_script
Output will always be 5 values. Or you can pull the snippet into your script.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-26-2001 10:26 PM
тАО02-26-2001 10:26 PM
Re: OK...I need some shell script help..
What I would do:
while read line
do
set -- $line "" "" "" "" ""
done < your_file
That way, $1 to $5 always get filled up, even when your line only contains 3 (or less) fields (words). The 4th and 5th word will be empty, but you will not get an error (be sure to quote your variables when doing a prinf!!)
Hope this helps,
Rik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 05:47 AM
тАО02-27-2001 05:47 AM
Re: OK...I need some shell script help..
join is very usefull for me.
See also:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x5cfe6c96588ad4118fef0090279cd0f9,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-27-2001 06:14 AM
тАО02-27-2001 06:14 AM
Re: OK...I need some shell script help..
a very simple printf statement in the posix shell;
printf "%-x.xs%-x.xs%-x.xs%-x.xs%-x.xs\n" "$1" "$2" "$3" " $4" " $5"
where -x.x is used for presentation ;o)
by adding the space in front of $4 and $5 the argument to printf is always filled.
Greetz, Danny.