`setx nas_scratch 0 -m`; (@queueitems)=split(/\s+/,$lineitem); foreach (@queueitems) { my $tapeid = $_; $ENV{NAS_SCRATCH}=$tapeid; ## shell out to Junction command using oprcmd? while ($ENV{NAS_SCRATCH} != 0) {## wait until external command finishes sleep(5); ## hold 5 secs and check again }