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!

Help with control structures

Status
Not open for further replies.

siswjh

MIS
Dec 6, 2001
63
US
Here is the script:

#!/usr/bin/perl -w

Code:
@tape = `vmquery -pn NT_Offsite_Pool`;
if ($tape[6] eq "TLD - Tape Library DLT (8)") {
print $tape[1];
}
The script is supposed to query netback for tape that are in the NT_Offsite_Pool. When it finds a line with TLD - Tape Library DLT (8) it prints field one which is the tape barcode. The problem is that it does not move through the array. It does the first one but does not go through the whole array. What am I missing. The script is being run on a Solaris master with solaris 8 installed.

Thanks for any help.
 
@tape = `vmquery -pn NT_Offsite_Pool`;
if ($tape[6] eq "TLD - Tape Library DLT (8)") {
print $tape[1];
}


OK so you made your array and then told it to run if $tape[6] is equal to your string. That only tells it to run once.


Are your trying to do this?

foreach $value (@tape){
if ($value eq "TLD - Tape Library DLT (8)") {
print $tape[1];
}
}

Evaluates each value in the array against your string.

Shelby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top