Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 878637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:48:00+00:00 2026-05-15T11:48:00+00:00

I have the following perl script that works locally given the input parameters. I

  • 0

I have the following perl script that works locally given the input parameters.
I need the script to access remote servers for the same information, given that I’ve already setup the ssh keys successfully. The path for the logfiles on the remote servers are identical to local. Configuration for remote servers are identical. I just need to run across multiple servers and bring back the data either to terminal or on a file. Do I need to put this in a shell script?

# usage example: <this script> Jun 26 2010 <logfile>
use strict;
use warnings;
my ($mon,$day,$year) = ($ARGV[0],$ARGV[1],$ARGV[2]);
open(FH,"< $ARGV[3]") or die "can't open log file $ARGV[3]: $!\n";
while (my $line = <FH>) {
    if ($line =~ /.* $mon $day \d{2}:\d{2}:\d{2} $year:.*(ERROR:|backup-date=|host=|backup-size=|backup-time=|backup-status)/) {
    print $line;
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:48:01+00:00Added an answer on May 15, 2026 at 11:48 am

    You could modify the script to take the server name as an extra argument.

    # usage example: <this script> Jun 26 2010 <server> <logfile>
    use strict;
    use warnings;
    my($mon,$day,$year,$server,$file) = @ARGV;
    open(my $fh,"ssh $server cat $file |") or die "can't open log $server:$file: $!\n";
    while (my $line = <$fh>) {
        if ($line =~ /.* $mon $day \d{2}:\d{2}:\d{2} $year:.*(ERROR:|backup-date=|host=|backup-size=|backup-time=|backup-status)/) {
        print $line;
       }
    }
    

    My version takes advantage of the fact that the Perl open function can ‘open’ a command and the output from the command is presented as input to your script.

    —- edit

    Regarding your follow-up question, if the file exists in the same place on a number of hosts then you could swap the argument order around and pass the list of hosts on the command-line:

    # usage example: <this script> Jun 26 2010 <logfile> <server> ...
    use strict;
    use warnings;
    my($mon,$day,$year,$file) = @ARGV;
    splice(@ARGV, 0, 4, ());            # Discard first 4 args
    foreach my $server ( @ARGV ) {
        open(my $fh,"ssh $server cat $file |") or die "can't open log $server:$file: $!\n";
        while (my $line = <$fh>) {
            if ($line =~ /.* $mon $day \d{2}:\d{2}:\d{2} $year:.*(ERROR:|backup-date=|host=|backup-size=|backup-time=|backup-status)/) {
                print $line;
            }
        }
        close($fh);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting problem. I wrote the following perl script to recursively loop
I have the following, simplest Perl CGI script: use strict; use warnings; use CGI();
I have a perl script that will perform some operations on directories, and I
I have a perl script that pulls serialized php data from a database, unserializes
I have the following line in my Perl script: s/b(w+)b/ $replaces{$1} ? $replaces{$1} :
I have a really trivial perl script that I would like to distribute to
I currently have a perl script that imports HTML and converts it to plain
I have a script that appends some rows to a table. One of the
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have following string String str = replace :) :) with some other string;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.