As for your errors... they don't look Perl related. Perhaps there is some other reason that you can't delete a drive... like some process has some kind of lock on a file in the drive.use strict; my $drive; my $count = -1; open( LIST, "tpconfig -l|" ) or die $!; while( <LIST> ) # I added the <LIST>... which I suspect you had. { ($drive) = unpack '@0 A8',$_; ++$count if m/^drive/; system("tpconfig -delete -drive -index ${count}"); # You should check all system calls for error. # system will set $? to an error code for you. }
Update: You can read up on $? here
Another Update:
raj8 says the script deletes the drives, but still generates the errors.
The "problem" is that system doesn't capture STDERR. The way to circumvent this is to redirect to nul: BUT BEWARE! This will hide ALL error messages from the system call!
Try this:
Also, be sure to read chromatic's post. He raises a good point about when you make the system call, although I suspect that since there are only two robots and four errors that this isn't the complete answer. (Although I would bet good money that it does explain the duplicity of the index 0 error).system("tpconfig -delete -drive -index ${count} 2>nul:"); die "Unknown Error with tpconfig $count" if $? >> 8;
In reply to Re: Increment
by Adam
in thread Increment
by raj8
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |