Here is the requirement:

I need to write a perl script to have the follow function:

Input: IP,Username,Password,command,protocal

Process: Login the switch (according to the IP) via SSH1 or SSH2 (according to the Protocal), then execute the given command

Output: The result from the switch.

Example:

Input:1.1.1.1,cisco,cisco,show version,SSH1

The script should be able to run in the following enviroment:

1. Redhat+Perl

2. WinXP+ActivePerl

So I tried the following:

1. Net::SSH::Perl - Too many dependency, can not insatll successfully and the same with Net::SSH::W32Perl.(Because of the net connection limit I must install mannuly)

2.Net::SSH::Expect for SSH1, Net::SSH2 for SSH2, this works good under linux but the Net::SSH::Expect can not be insatll under windows because of the dependency of IO::PTY (works in Cygwin though .....Why.....)

3.OpenSSH, I think this may work but I'll have to write some codes myself instead of using the package, but now I've even no idea how to write code to login the switch using SSH command (Although I know how to loging the switch by typing the command in the shell or cmd via interactive mode)

Any suggestion or advice would be great, thanks^_^


In reply to Looking for suggestion... by SuperSu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.