ADSM-L

Re: Scripting queries with perl

1997-02-05 15:01:50
Subject: Re: Scripting queries with perl
From: Owen Crow <crow AT SUGAR-LAND.MIS.SLB DOT COM>
Date: Wed, 5 Feb 1997 14:01:50 -0600
At 11:00 AM 2/5/97 -0800, Thomas A. La Porte wrote:
>Environment: AIX v2.1.8 server, IRIX v2.1.5 client.

You forgot to mention your Perl version.

>I've written a perl script to generate a formatted list of
>volumes to be retrieved from our offsite storage vault. I've run
>into a problem, however, due to the paging of the
>information that is returned:
>(i.e.: "more...   (<ENTER> to continue, 'C' to cancel)" )
>
>The relevant snippet of Perl code is:
>
>open(DSMVAULTR, "/bin/dsmadmc -id=admin -pa=password q drm \"*\"
>     wherest=vaultr|")  || die ("Error: $!\n");
>
>Since the process of the command line is expecting input, the
>DSMVAULTR file handle never returns an EOF.

I think we may need more info. I'm using code similar to this
to combine "q libv" with the stgpool for each volser without the
effect you mention. I use a different type of open(), but I
tried it with your format with positive results. I'll include
the script I use at the end of this message.

BTW, the "|| die" function doesn't do what you think on a pipe.
The open will always work (unless there's a syntax error) even if
the executable you try to run does not exist. Check the close()
instead: close DSMVAULTR or die "Error during pipe: $!";

Here's how I do it:

#!/common/bin/perl -w

# Parse "query libv" and "query volume" commands from dsmadmc to add
# stgpool info to a normal "q libv".

use strict;

if ( ! defined $ARGV[0] || ! defined $ARGV[1] ) {
  warn "You must supply your ADSM Administrator ID and password as",
    " arguments\n";
  exit 2;
}

# Open and parse the "query volume" command. Pick out tape volumes along
# with their sgtpool
open QV, "/usr/bin/dsmadmc -id=$ARGV[0] -pass=$ARGV[1] q v dev=tape3590|";
my %pools;

while (<QV>) {
  next if ( $_ !~ /^H\d{5}?/i ); # Our tapes are all start with H
  @_=split;
  $pools{$_[0]}=$_[1] if ( $_[1] );
}

# Close the pipe and check for problems.
close QV or die "Problem during q v pipe: $!";

# Open and parse the "query libvolume" command. Add stgpool info for each
# tape as we go.
open QLIBV, "/usr/bin/dsmadmc -id=$ARGV[0] -pass=$ARGV[1] q libv|";

while (<QLIBV>) {
  next if ( $_ !~ /^AUTOMOUNT1/ ); # Our only library is AUTOMOUNT1
  chomp;
  @_=split;
  if ($pools{$_[1]}) {
    print "$_ $pools{$_[1]}\n";
  } else {
    print "$_\n";
  }
}

close QLIBV or die "Problem during q libv pipe: $!";

Owen Crow
UNIX System Administrator
<Prev in Thread] Current Thread [Next in Thread>