-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

5
  • 1
    see this stackoverflow.com/questions/2848725/… Commented Dec 31, 2012 at 6: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. Commented Dec 31, 2012 at 6: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.) Commented Dec 31, 2012 at 6: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, should work perfectly fine in Perl 5.6.1. Commented Dec 31, 2012 at 6: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? Commented Dec 31, 2012 at 8:59

2 Answers 2

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');
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.