Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting list 2

Status
Not open for further replies.

blarneyme

MIS
Jun 22, 2009
160
US
Previously I was getting a list like this:
Code:
@list = `vxdisk -o alldgs list | grep $VARIABLE`

But this method will no longer work, so I'm trying to get @list in another way but am stumped. I have a list of devices in a file like /tmp/devices which contains
Code:
sda
sdb
sdc

There are other devices such as sdd, sde, sdf, and are in the same disk group but are clones, so I need to be specific so I only get my R2, BCV1, BCV2 devices.

How would I get @list using the /tmp/device list?

Thanks.
 
It's not very perl-y, but this should do it:

Code:
@list = `vxdisk -o alldgs list | grep -wf /tmp/devices $VARIABLE`

A more perl-y way:

Code:
[gray]#!/usr/bin/perl[/gray]

[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]
[black][b]use[/b][/black] [green]warnings[/green][red];[/red]

[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]%devs[/blue][red];[/red]

[url=http://perldoc.perl.org/functions/open.html][black][b]open[/b][/black][/url] DEVS,[red]"[/red][purple]/tmp/devices[/purple][red]"[/red] or [url=http://perldoc.perl.org/functions/die.html][black][b]die[/b][/black][/url] [red]"[/red][purple]missing /tmp/devices?[/purple][red]"[/red][red];[/red]
[olive][b]while[/b][/olive] [red]([/red]<DEVS>[red])[/red] [red]{[/red] [url=http://perldoc.perl.org/functions/chomp.html][black][b]chomp[/b][/black][/url][red];[/red] [black][b]my[/b][/black] [blue]@a[/blue]=[url=http://perldoc.perl.org/functions/split.html][black][b]split[/b][/black][/url][red]([/red][red])[/red][red];[/red] [blue]$devs[/blue][red]{[/red][blue]$a[/blue][red][[/red][fuchsia]0[/fuchsia][red]][/red][red]}[/red]=[fuchsia]1[/fuchsia][red];[/red] [red]}[/red]
[url=http://perldoc.perl.org/functions/close.html][black][b]close[/b][/black][/url] DEVS[red];[/red]

[black][b]open[/b][/black] VXDISK,[red]"[/red][purple]vxdisk -o alldgs list |[/purple][red]"[/red] or [black][b]die[/b][/black] [red]"[/red][purple]unable to run vxdisk[purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[olive][b]while[/b][/olive] [red]([/red]<VXDISK>[red])[/red] [red]{[/red] [black][b]my[/b][/black] [blue]@a[/blue]=[black][b]split[/b][/black][red]([/red][red])[/red][red];[/red] [url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [olive][b]if[/b][/olive] [red]([/red][url=http://perldoc.perl.org/functions/defined.html][black][b]defined[/b][/black][/url] [blue]$devs[/blue][red]{[/red][blue]$a[/blue][red][[/red][fuchsia]0[/fuchsia][red]][/red][red]}[/red][red])[/red][red];[/red] [red]}[/red]
[black][b]close[/b][/black] VXDISK[red];[/red]




Annihilannic.
 
vxdisk seems to support a list of devices specified after the list. Maybe you could just construct the command this way to avoid the grepping?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top