-1

Possible Duplicate:
How can I ssh inside a Perl script?

Please let me know if there is any way we can write a perl script to login to a linux machine and execute a command.

Problem here is I need to use Perl - 5.6.1 version where none of the SSH modules were available

Community
  • 1
  • 1
Tkills
  • 61
  • 1
  • 6
  • 1
    see this http://stackoverflow.com/questions/2848725/how-can-i-ssh-inside-a-perl-script – harish.venkat Dec 31 '12 at 06:23
  • It's rather silly to say you want to do something with a specific tool and say the tool you want to use can't do it in the same sentence. Why is this tagged Perl when you specifically say it can't be done using your `perl`? All the answers you get will of course ignore your requirement. – ikegami Dec 31 '12 at 06:48
  • Perhaps you are actually trying to find out how to use `ssh`? Perhaps you are actually trying to find out how to execute an external program? If so, your question needs fixing. (Well, I'd personally delete it and start fresh.) – ikegami Dec 31 '12 at 06:50
  • 1
    Or are you hoping to be caught in a lie? The first module that came up in a search of `ssh` on CPAN, [Net::SSH](http://search.cpan.org/perldoc?Net::SSH), should work perfectly fine in Perl 5.6.1. – ikegami Dec 31 '12 at 06:52
  • You could help us help you by describing what it is you're doing? You could write a bash script to ssh if you what some kinda automation done, what are you trying to accomplish by `programatically doing an ssh`? – gideon Dec 31 '12 at 08:59

2 Answers2

1

I tried a program and it works.

Hope you can use this too by modifying a bit.

#!/usr/bin/perl

use strict;

system('ssh krishna\@host\.com');
Krishnachandra Sharma
  • 1,332
  • 2
  • 20
  • 42
0

You can always use a system() call to run the ssh client (using public-key authentication), if one is available. If you are on Windows, you may want to check if you can do it with some PuTTY command line options.

Make sure to properly escape your system call if it is not a constant value to avoid shell injections.

Jan Schejbal
  • 4,000
  • 19
  • 40