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

  • SEARCH
  • Home
  • 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 8793059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:04:29+00:00 2026-06-13T23:04:29+00:00

I am having a bit of a problem with a script that I setup.

  • 0

I am having a bit of a problem with a script that I setup. A little background:

The function of the script is to read from a list of servers that is in a text file separated by :: , log on to the servers, check to see that mysql is running and report back. The file is configured such that each line has: Servername::Ip address::port number

The problem I am having is that I think perl is trying to concatenate the ip address that I am feeding to the function I have in the code. Can anyone point my in the right direction?

#!/usr/bin/perl                                                                                           

use strict;
use warnings;

open(FH, '<', 'serverlist_test') or error("Cannot open file , ($!)");
while (my $line = <FH>) {
    our ($name, $ip, $port) = split(/::/, $line);
    my $version = &MySQL_check($ip, $port);                                                                                    
}
close FH;

sub MySQL_check {

    my $issue = `ssh -t root@"$_[0]" -p$"_[1]" 'ps axco command | grep -i mysql'`;
    print $issue;
    if ($issue =~ /mysql/) {                                                                             
      return "Mysql found"; 
    } else {                                                                                             
       return "Mysql not found";                                                                         
    }                                                                                                    
}

What am I doing wrong?

Thank You.

  • 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-06-13T23:04:30+00:00Added an answer on June 13, 2026 at 11:04 pm

    Put in some print-debugging code so you can see the command being run. So change:

    my $issue = `ssh -t root@"$_[0]" -p$"_[1]" 'ps axco command | grep -i mysql'`;
    

    to

    my $command = qq`ssh -t root@"$_[0]" -p$"_[1]" 'ps axco command | grep -i mysql'`;
    warn "Going to run \"$command\""; # comment this out when your code works!
    my $issue = `$command`;
    

    This should flag up the problem with the command. It’s almost certainly because you didn’t chomp the lines you read from the file, so the port number actually has \n after it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of a problem, drawing text on an image. When I'm
I'm having a bit of a problem with moving specific data from one server
I'm having a little bit of trouble making OpenID work from within an iframe.
i'm having a bit of a problem here. I found this script on the
I need a script that can write text to an exsisting file starting on
The problem I am having is that my jquery script is not returning the
I'm having a bit of a problem getting my custom JavaScript file to play
I'm having a bit problem with reading argument value in haskell: I'm having options
Having a bit of a problem, Due to the source-control set-up we use, each
Having a bit of a problem creating an instance of an object. Bear in

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.