use strict; use Expect; my $session = new Expect; unless ($session->spawn("telnet $mach_connect")) { print "FATAL: could not connect to $tgt_mach\n"; exit 1; } ... login code here to bring the user to the prompt on the remote host open(FILEHANDLE,"+< $filename"); ... work on the file close(SNMPFILE);