Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How do I invoke a procedure on a server remotely?

( #6721=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Apr 03, 2000 at 17:58 UTC
Q&A  > network programming


Description:

I have a script on web server and I would like to invoke a script on another server from this script. How do I go ahead with it . Help Needed ASAP -Vishu

Answer: How do I invoke a procedure on a server remotely?
contributed by penguinfuz

Another option, assuming you've got a working SSH connection between the machines is to use Net::SSH::Perl.
Note: Cpan search seems to be having issues at the moment so here's an alternative location - Net::SSH::Perl.

sub run_remote_script { use Net::SSH::Perl; my ($host,$user,$pass,$opt1,$opt2,$opt3) = @_; my $cmd = "/path/to/remote_script $opt1 $opt2 $opt3"; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user,$pass); my %output; ($output{stdout},$output{stderr},$output{exit}) = $ssh->cmd($cmd); return \%output; }
Answer: How do I invoke a procedure on a server remotely?
contributed by chromatic

If you want to get the output from another script, it's as simple as using LWP::Simple. See How can I load a webpage into my program?. That assumes that the script on another server is CGI and available through HTTP access.

If you're looking to execute a script through rsh or ssh or telnet, look for the Expect module. You can write something like a chat script with it.

Answer: How do I invoke a procedure on a server remotely?
contributed by casiano

If you can establish an automatic ssh connection with the server, use GRID::Machine

Answer: How do I invoke a procedure on a server remotely?
contributed by btrott

It sounds like you're just asking about invoking a remote script as you might through a web browser (as opposed to a particular procedure). But just in case you were asking about RPC: How can I do RPC in Perl?.

Answer: How do I invoke a procedure on a server remotely?
contributed by Mago

my $tn; # Telnet connection initilized sub TNcommand { my($command) = $_[0]; &RunLog (" : Running command = $command"); $tn->cmd(String => $command, Prompt => '/\>$/'); return; } sub TNprint { my($command) = $_[0]; &RunLog (" : Running print command = $command"); $tn->print("$command"); return; } sub TNwriteFile { my($out_fname) = $_[0]; my($NextLine) = "1"; open (SAIDA, ">$out_fname"); while ($NextLine) { if ($NextLine = $tn->getline(Timeout => 15)) { $NextLine =~ s/\r//; print SAIDA $NextLine; } } close SAIDA; return; }

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (2)
    As of 2014-09-20 22:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (163 votes), past polls