yadavdipak has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am new to Perl. I am trying to do telnet on SCO unix using Net::Telnet module of perl. But I am unable to do so. The same piece of code is working good for solaris server. I don't know what extra configuration settings I have to do for SCO.

Plz help me on this matter.

thanks,

-dipak

Here is the code :

$host = new Net::Telnet (Timeout => 30, Prompt => '/[%#>] $/'); $prev = $host->errmode("return"); $host->open ($server_name); $host->login($user_name, $pass_word); $$msg = $host->errmsg; $prompt = '_tibPrompt_'; $host->prompt("/$prompt\$/"); $host->cmd("set prompt = '$prompt'"); ####### Get the disk usage. $dsk_cmnd = "df -k"; @disk_result = $host->cmd($dsk_cmnd);
<small edited by castaway, added tags.

Replies are listed 'Best First'.
Re: telnet on sco using perl
by BUU (Prior) on Oct 02, 2003 at 22:17 UTC
    "unable to do so". Somebody is physically preventing you from doing so? Aliens are intercepting your code and killing it? NEED ERROR MESSAGES AND DETAILS.
Re: telnet on sco using perl
by JamesNC (Chaplain) on Oct 03, 2003 at 12:11 UTC
    1. You can try enabling the log files to debug by adding "Dump_Log => $logfile, " to your instantiation of the Net::Telnet object.
    2. If you see what looks like odd characters mixed in there, it is because Net::Telnet defaults to NVT as its TERMINAL type and the Telnet server you are connecting to didn't negotiate that TERM TYPE properly with Net::Telnet, and so the Telnet server defaults to whatever it's default TERM is (usually vt100 or vt52) and starts sending escape characters with the text. The author of Net::Telnet developed it for Unix so I don't think this may be your problem, but if it is then here are 2 solutions: 1) Rewrite the Net::Telnet module to handle the escape characters or negotiate the correct TERM TYPE. 2) Use a filter to strip out the ANSI Escape characters. If you look here Remove Escape Codes I have provided a solution to removing the escape codes for 2 TERM TYPES so Win32. I have a telnet client that I wrote for learning purposes if you want to see what is going on in more detail with the telnet protocol.

    Cheers,
    JamesNC