Odd script problem (sshpass)

  • 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, so will work, but 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 Name or service not known"

  • Service Provider

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

  • It is the same thing. I can replicate by running "ping" on the same machine hosting the SSHpass script and it works but the "ping" 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.

  • 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...

  • 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 the response came back from because 77 in octal equals 63 in decimal. Lesson learned for me trying to overcomplicate things.