I think it's your ++$count that's the problem. The drive numbers are sequential, but you have lines that begin with 'robot'. You don't increment $count for these lines (good) but you do the
system command (not so good). Perhaps you should skip out of the loop early if you run into a robot:
next if /^robot/;
$count++;
system( ... );
Without having anything named 'tpconfig' on my system, I can't check the man page for error messages, but I would be surprised if it allowed you to delete a drive you'd just deleted. The numbers seem to be fairly close.
Update: Here's a more complete code segment that really ought to do it for you:
my $drive;
my $count = 0;
open( LIST, "tpconfig -l|" ) or die $!;
while(<LIST>) {
($drive) = unpack '@0 A8',$_;
next unless /^drive/;
(system("tpconfig -delete -drive -index ${count}") == 0) or print
+"Error deleting: $?";
$count++;
}
Starts at 0, doesn't execute the command unless it's found a drive. Increments the number after it executes the command, checks
$? for errors. (I'm not 100% certain about the syntax of that
system checking, but it was in
perlfunc that way.)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.