Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
...it's still horrible.
you should get rid of about 90% of the pipes and make this into a real shell script, otherwise it will be humanly impossible to troubleshoot
:-(
A single line script?
Here is a multi-line script, that is complicated enough. The major part runs on the local host.
Code:
#!/bin/bash
for i in `cat server-list.txt`
do
echo "+++++++++ $i +++++++++"
ssh -qnx "$i" '/sbin/ifconfig' |
while IFS="" read line
do
case $line in
(lo*)
if=""
;;
([a-z]*)
if="${line%% *}"
addr=""
;;
(*\ inet*:*)
addr="${line#* inet*:}"
addr="${addr# }"
addr="${addr%%[ /]*}"
case $addr in
(127.0.0.1|::1)
addr=""
;;
esac
;;
esac
if [ -n "$if" -a -n "$addr" ]
then
read ip hst junk < <(getent hosts "$addr")
echo "$if $addr $hst"
addr=""
fi
done
done
thanks four your inputs. i've tried those but that didn't work as expected. For this time, i executed the paste commands individually and later merged them... that was really hectic.
i m still looking for a working solution. It is not mandatory to use paste command, anything will work which can put the interface, ip address and fqdn of that ip in the same line with a space or tab between them.
What's wrong with my post#4?
Did you run it on the command line?
Do you get an error message? Does it get stuck?
What output do you get, and what do you expect?
The single quote after awk doesn't start a quoted string, it ends the string which started with paste. And a backslash doesn't seem to protect a single quote, so that's not a solution.
Although, MadeInGermany's approach of only running ifconfig once and processing the output on the local machine has a lot of merit. Also notice he used getent instead of nslookup.
thanks four your inputs. i've tried those but that didn't work as expected. For this time, i executed the paste commands individually and later merged them... that was really hectic. i m still looking for a working solution. It is not mandatory to use paste command, anything will work which can put the interface, ip address and fqdn of that ip in the same line with a space or tab between them.
Ok...so why don't you then post what YOU have written/done/tried on your own to get this going??? As you were told before, we WILL NOT write your script for you. Show your own efforts, and we can help you work through problems. If you don't...there is not much we can do for you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.