Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Net::Telnet + command prompt

by regexes (Hermit)
on Mar 07, 2008 at 10:12 UTC ( [id://672727]=note: print w/replies, xml ) Need Help??


in reply to Net::Telnet + command prompt

Hello,

To expand on NetWallah's response...

I find it easier to set my own prompt. That way you always know what's being returned. Look at Net::Telnet --> method: prompt

Here's an example:
$host->login( $username, $password ); my $prompt = "_MYPROMPT_"; $host->prompt("/$prompt\$/"); $host->cmd("prompt = $prompt");
I don't what you're programming/developing but another thing you might want to be aware of is the trickiness of Microsoft's own "telnet server".

See the Net::Telnet documentation under the heading: Connecting to a Remote MS-Windows Machine

Hope it helps..

regexes


-------------------------
Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan "press on" has solved and always will solve the problems of the human race.
-- Calvin Coolidge, 30th President of the USA.

Replies are listed 'Best First'.
Re^2: RESOLVED: Net::Telnet + command prompt
by brwarn (Novice) on Mar 07, 2008 at 17:43 UTC
    Solved! The code to do so is the following:

    foreach $host (sort @hosts) { $t = new Net::Telnet (Timeout => 10, Input_log => $file, Prompt => "/\>/"); print "\n\nConnecting to $host ...\n"; $t->open("$host"); $t->login("abc","abc123"); my @lines = $t->cmd('dir'); print "$host: Directory Contents:\n"; print "@lines \n"; $t->close; }
    Thanks to all for your help.
      Hi everyone, I'm trying to connect through telnet to windows ce, but the prompt is "\> " I don't can to send commands because I've this error: pattern match read eof at telnettest.pl line 185"" please someone who can help me!!!
        Hey check if the host to which you are trying to telnet is accepting connections. This generally occurs when the telnet connection cannot be established.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://672727]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-25 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found