On Wed, 11 Jun 2008 21:20:49 +0530
<[EMAIL PROTECTED]> wrote:
> Hi All,
> 
>       I want to telnet through Perl script from Windows m/c to Linux.
> Is there any way which we can achieve this without using any ssh
> module like Net::FTP & Net::SSH::W32Perl?
> 
> If you have any code snippet please send me across.
> 
> Thanks for your kind help in advance.
> 
> Regards,
> Mustafa
> 

You can open a pipe to an ssh binary on windows? I've had some luck
doing so, like this:

<code>
#!Perl
use strict;
use warnings;

use IPC::Open2;

my %config = ( user=>'theuser',
               password=>'xxxx',
               host=>'test.com',
               ident=>"$ENV{HOMEDRIVE}$ENV{HOMEPATH}\\.ssh\\key.rsa",
               );

$config{ident}=~tr/\\/\//;
$config{ident}='"'.$config{ident}.'"'; #cyg-happy path

my @cmds = ( "ls -l", 
"cd dump;ls -1 |mail -s 'dump list' [EMAIL PROTECTED]");

foreach my $cmd (@cmds){
    my $result = command ($cmd); # ,\%config
    print $result if ($result);
    }

sub command {

    my $cmd = shift; 
    my $result;

    my $pid = open2( \*READER, \*WRITER, 'ssh',
                        "-i $config{ident}",
                        "[EMAIL PROTECTED]",
                        $cmd) || die "ssh: $!";

     while (<READER>) {
         $result .= $_;
         }
     close(READER);
     close(WRITER);
     return $result;
}
</code>

with this openssh cygwin port available here:
http://sourceforge.net/project/showfiles.php?group_id=103886

TIMTOWTDI, I'm sure.

HTH.

Cheers,

-- 
    Michael Higgins

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to