script help please


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting script help please
# 8  
Old 03-19-2008
Question How about this as output?

Quote:
> cat tmp_vgaaa.srt
t9d0
t9d2
t9d4
from this original file:
Quote:
> cat disklist
/dev/vgaaa
/dev/dsk/c8t9d0
/dev/dsk/c8t9d2
/dev/dsk/c8t9d4
/dev/dsk/c9t9d0
/dev/dsk/c9t9d2
/dev/dsk/c9t9d4
/dev/vgabc
/dev/dsk/c8t9d1
/dev/dsk/c8t9d3
/dev/dsk/c9t9d1
/dev/dsk/c9t9d3
/dev/vgbbb
/dev/dsk/c8t7d0
/dev/dsk/c8t7d0
based on this coding:
Code:
> cat rev_dsk
#! /bin/bash

#remove any existing work files
rm tmp_*

#assumes file disklist exists; listing from lvm
while read zf
   do
   chkvar=$(echo "$zf" | cut -c6-8)
#   echo $chkvar
   if [ "$chkvar" = "dsk" ]
      then
         devvar=$(echo "$zf" | cut -c10-)
         diskvar=$(echo "$devvar" | cut -d"t" -f2)
         echo "t""$diskvar" >> "$vgrp"
      else
         filevar=$(echo "$zf" | cut -c6-)
         vgrp="tmp_""$filevar"
   fi
done < disklist 

for yf in tmp_*
   do
   sort -u "$yf" > "$yf"".srt"
done

If this is along the correct lines, the script could probably also tell the "c" values (=c8 and c9) for any volume group. Before going to that extent, and not sure if you need, want to see if this brings you in the correct direction.
# 9  
Old 03-19-2008
If none of the replies thus far have helped you, please be more specific. I've read through this thread several times and I'm still not sure what you are looking for.

You're using terms such as Powerpath, vgimport, PV links, etc., all of which mean nothing at all to me.

If you can, explain it in generic way, posting lines of sample input file(s) and desired output, and any rules which need to be applied to get us from A to B without having to understand your infrastructure.

Thanks,
Shawn
# 10  
Old 03-19-2008
OK let me try to be as direct as possible:
I have a list. See example above. On one line will be the name of the Volume Group. All of the lines after that will be devices belonging to that Volume Group until a new Volume Group is reached in the list. See example above. It is easy to tell the difference between devices and Volume Groups because the devices will all start with /dev/dsk.

I want to output all of the devices pertaining to a specified Volume Group. Only the disks belonging to that Volume Group and nothing else. I will specify via a variable which Volume Group I am looking for.

Secondly, there may be multiple I/O paths to any device but the number of paths can vary. In this case, a single disk will have two or more device files starting with /dev/dsk in this list. I only want to list one device file for each physical disk. See example and sample output above. This can be distinguished by the controller id. The c represents the controller, i.e. c9t13d2 is the same physical disk as c4t13d2 but the I/O path is to a different controller.

For each unique Volume Group I want to output to a file only the unique disks for that Volume Group. I do not care which controller is used (the c number), only that the disks are unique (the t and d numbers, aka. target and device numbers).

I am sorry to have confused anyone with the technical reasoning behind this but I knew that if I did not state my purpose that people would want to know why I was doing it so that they may try to come up with alternative solutions. Hopefully this makes sense because I'm not sure how else to explain it.

Thank you everyone for your responses so far. By the way, this is an HP-UX server and there is no bash installed. Everything I do is therefore written in ksh or Posix shell (which is pretty much similar to ksh).
# 11  
Old 03-24-2008
Well after a few days of thought this is what I was able to come up with. Please let me know if you can think of a cleaner or more efficient way of doing this.

#!/usr/bin/ksh
VG="vgabc"

for i in `strings /etc/lvmtab | awk 'BEGIN {x=0}
{
if ($0 ~ /'$VG'/ ) {getline; ++x}
if ($0 !~ /dsk/ ) {exit}
if (x == 1) { split($0, t_d_ , "dsk"); split(t_d_[2],t,"t"); split(t[2],d,"d"); print "t"d[1]"d"d[2]}
}' | sort -n | uniq`
do
strings /etc/lvmtab | grep $i | sort | head -n 1
done
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Shell script works fine as a standalone script but not as part of a bigger script

Hello all, I am facing a weird issue while executing a code below - #!/bin/bash cd /wload/baot/home/baotasa0/sandboxes_finance/ext_ukba_bde/pset sh UKBA_publish.sh UKBA 28082015 3 if then echo "Param file conversion for all the areas are completed, please check in your home directory"... (2 Replies)
Discussion started by: ektubbe
2 Replies

3. UNIX for Dummies Questions & Answers

Calling a script from master script to get value from called script

I am trying to call a script(callingscript.sh) from a master script(masterscript.sh) to get string type value from calling script to master script. I have used scripts mentioned below. #masterscript.sh ./callingscript.sh echo $fileExist #callingscript.sh echo "The script is called"... (2 Replies)
Discussion started by: Raj Roy
2 Replies

4. Shell Programming and Scripting

Script will keep checking running status of another script and also restart called script at night

I am using blow script :-- #!/bin/bash FIND=$(ps -elf | grep "snmp_trap.sh" | grep -v grep) #check snmp_trap.sh is running or not if then # echo "process found" exit 0; else echo "process not found" exec /home/Ketan_r /snmp_trap.sh 2>&1 & disown -h ... (1 Reply)
Discussion started by: ketanraut
1 Replies

5. Shell Programming and Scripting

create a shell script that calls another script and and an awk script

Hi guys I have a shell script that executes sql statemets and sends the output to a file.the script takes in parameters executes sql and sends the result to an output file. #!/bin/sh echo " $2 $3 $4 $5 $6 $7 isql -w400 -U$2 -S$5 -P$3 << xxx use $4 go print"**Changes to the table... (0 Replies)
Discussion started by: magikminox
0 Replies
Login or Register to Ask a Question