kotak86 has asked for the wisdom of the Perl Monks concerning the following question:

Hi I have Perl script (with set of system command in `sys command`). I wanted to run this script in other list of server that I can provide at the run time of my local server. Also I can not use Expect/ Net::SSH module or any other CPAN module. My script is running perfectly fine in my local machine, but when I have place the block of code, it seems it do not have reference to the script and can perform any other line of code after doing ssh to the specific server. e.g. script name: servervalidation.pl my script should first take the server, and ssh to that server and then in that server login as su and then perform some set of command and get the information and send back to the local server from which I run he script. take argument: list_of_server File content :servera, serverb, serverc......
  • Comment on Execute Perl script on Remote server without any CPAN module

Replies are listed 'Best First'.
Re: Execute Perl script on Remote server without any CPAN module
by salva (Canon) on Jan 29, 2014 at 08:39 UTC
    And I would like to cross the Atlantic without a boat, swimming.

    It can be done, but unless you are here for the sport, you better rethink that point about not using a boat!

      "And I would like to cross the Atlantic without a boat, swimming."

      I like this. I'll have to remember it for future use.

      use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
Re: Execute Perl script on Remote server without any CPAN module
by NetWallah (Canon) on Jan 29, 2014 at 04:40 UTC
    Welcome to the Monastery!

    It is fairly obvious that English is not your first language, but we still need a clearer expression of what you have tried, what you expect it to do, and what the actual results were.

    Please review How do I post a question effectively?.

    Generally, we will happily assist you with correcting and advising on specific perl issues, but we do not offer a code writing service.

            What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
                  -Larry Wall, 1992

Re: Execute Perl script on Remote server without any CPAN module
by FloydATC (Deacon) on Jan 29, 2014 at 11:10 UTC
    ... it seems it do not have reference to the script and can perform any other line of code after doing ssh to the specific server ...

    In the absence of detailed info, I'll make a few assumptions and have some fun guessing :-)

    If your script simply uses the ssh command to execute shell commands, Perl isn't really the challenge but rather how good you are at extracting information using shell one-liners. Then you can process that information in your local Perl script.

    If, on the other hand, you are trying to remote into a host using ssh to execute a local copy of a Perl script, you will first have to make sure a local copy of that Perl script exists on the remote host. You will probably want to look into both "scp" (copy files via SSH)."

    In either case, you'll probably want to look into how to set up password-less (key based) SSH authentication so you won't have to deal with password prompts etc. But please make sure you understand the security implications of allowing password-less authentication. I'm not saying it's worse than hard-coding passwords in a script, but you have to think it through all the same.

    -- FloydATC

    Time flies when you don't know what you're doing

Re: Execute Perl script on Remote server without any CPAN module
by marto (Cardinal) on Jan 29, 2014 at 10:56 UTC

    Like others, I'm confused as to what you're trying to do. If you have a script which uses modules that can not be installed on a remote system (which is perhaps an issue you could address separately), consider packing the script and the required modules see PAR, PAR::Packer and PAR::Tutorial. If this is not what you are trying to do please try and explain what the problem is in a way others can understand. How do I post a question effectively?.