if( $options{protocol} eq 'ssh' ) { unless( defined $options{userid} ) { die "userid is a required parameter when using ssh\n"; } if( $options{login} and not defined $options{passwd} ) { die "passwd is a required parameter for ssh if login is true\n"; } @args = ( '/usr/bin/' . $options{protocol}, '-l', $options{userid}, '-p', $options{port}, '-q', '-o','StrictHostKeyChecking=no',$options{target} ); } elsif( $options{protocol} eq 'telnet' ) { @args = ( '/usr/bin/' . $options{protocol}, $options{target}, $options{port} ); if( $options{login} ) { unless( defined $options{userid} and defined $options{passwd} ) { die "userid and passwd are both required parameters for telnet if login is true\n"; } } } else { die "Unknown protocol specified: $options{protocol}\n"; } if( $options{logging} ) { unless( defined $options{logfile} ) { $options{logfile} = "$options{target}.log"; } open( $options{fh}, ">", $options{logfile} ) || die "Can't open file $options{logfile}: $!\n"; } # ============================================================================= # Spawn the child process to contact the target device # ============================================================================= $options{pty} = IO::Pty::Easy->new; $options{pty}->spawn(@args) or die "Unable to spawn child process: $!\n";