Hello All,
I have been working on a great script to remotely gather server info and store it in a .txt that can be imported to .xls
I have been reading the hostnames that are in the /.shh/known_hosts file so I don't have to mess with passing a password - via ssh (not easy to do , by the way, but posibble) anyway...
I have been stripping the known_hosts file of the following , trying to get a clean hosts.txt file to use as my CONFIRMED list of servers with exchanged keys.
I have removed the follow:
- ssh key
- extra charaters and extended hostnames
(e.g. myserver vs myserver_backup) So I would remove the "_backup"
- duplicates
So now I have something like the following
So I am looking to manage the text. move all hostnames to the first column and ip's to the 2nd comma separated spot. And move all single column enties to the bottom hostname first then ip's, but that doesn't really matter, just need to know how to manipulate the text, I know your going to say... reg expressions, but I want the easiest way or at least a way I can repeat and reuse for separate tasks.(something I understand)
I will then create an array and print them out via the array.
Thanks
I have been working on a great script to remotely gather server info and store it in a .txt that can be imported to .xls
I have been reading the hostnames that are in the /.shh/known_hosts file so I don't have to mess with passing a password - via ssh (not easy to do , by the way, but posibble) anyway...
I have been stripping the known_hosts file of the following , trying to get a clean hosts.txt file to use as my CONFIRMED list of servers with exchanged keys.
I have removed the follow:
- ssh key
- extra charaters and extended hostnames
(e.g. myserver vs myserver_backup) So I would remove the "_backup"
- duplicates
So now I have something like the following
hostname, 192.168.1.1
hostname2, 192.168.1.2
192.168.1.3, hostname3, hostname3.yahoo.com
hostname4
hostname5, 192.168.1.5
192.168.1.6
So I am looking to manage the text. move all hostnames to the first column and ip's to the 2nd comma separated spot. And move all single column enties to the bottom hostname first then ip's, but that doesn't really matter, just need to know how to manipulate the text, I know your going to say... reg expressions, but I want the easiest way or at least a way I can repeat and reuse for separate tasks.(something I understand)
hostname, 192.168.1.1
hostname2, 192.168.1.2
hostname3, 192.168.1.3
hostname5, 192.168.1.5
hostname4
192.168.1.6
I will then create an array and print them out via the array.
Code:
"@lines = map({[split /,/]} @lines);"
Thanks