You could try (untested):
my $output; chomp($output = `net use J: \\\\$hostname\\c\$`); if ($output =~ /successfully/) { print "You're in luck!\n"; }
If you're really partial to the third token idea, then split is your friend...
--In reply to Re: Grabbing tokens
by edan
in thread Grabbing tokens
by kidwahoo94
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |