ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Odd script problem (sshpass)

    IT Discussion
    2
    5
    832
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • SmithErickS
      SmithErick
      last edited by SmithErick

      Running a bash script (from Linux box) to sed some config files on local linux machines. It fails on every machine that has an 8 or 9 in the IP address. I am using leading zeros in the script (example: ping 10.0.1.077), so 10.0.1.077 will work, but 10.0.1.078 will not.
      The script pulls the IP list from a text file and the reason for the leading zeros is the last octet is a naming/number convention on the backend for something so it is used as a sed variable later in the script. This works without leading zeros, but I need the leading zeros for my variables. Any insight?

      Error message I get when an IP has an 8 or 9: "ssh: Could not resolve hostname 10.0.1.090: Name or service not known"

      1 Reply Last reply Reply Quote 1
      • scottalanmillerS
        scottalanmiller
        last edited by

        If you output the resulting variable to the screen, then manually copy and paste to see if SSH works that way, what happens?

        1 Reply Last reply Reply Quote 0
        • SmithErickS
          SmithErick
          last edited by SmithErick

          It is the same thing. I can replicate by running "ping 10.0.1.077" on the same machine hosting the SSHpass script and it works but the "ping 10.0.1.078" Its weird to me. I am logging into another machine on the network to see if it has the same issue.
          Edit: just tried pinging from a different machine with the same issue, 77 is good but anything with an 8 or 9 is bad. What the heck.

          1 Reply Last reply Reply Quote 0
          • SmithErickS
            SmithErick
            last edited by SmithErick

            Hold the phone... machines I have been pinging and sshpass'ing from are on a different network using OpenVPN. I ssh'd into a machine and can ping all the 8's and 9's just fine!
            Weird network issue then...hm...

            1 Reply Last reply Reply Quote 1
            • SmithErickS
              SmithErick
              last edited by

              Solution found, human thinking error. Because I was trying to make a bash script take the last octet of an IP address and use it in a config file for naming I was using leading zeros where I shouldn't be. Most modern OS's assume octal is being used when leading zero's are inserted into a number, octal is 0-7 so that is why 8 and 9's weren't working. Also when I did ping 10.0.1.077 the response came back from 10.0.1.63 because 77 in octal equals 63 in decimal. Lesson learned for me trying to overcomplicate things.

              1 Reply Last reply Reply Quote 2
              • 1 / 1
              • First post
                Last post