ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
ok, already wrote a long reply then my laptop choked...
ok, so i know what that feels like, i'd say that this sort of scripting *should* be easy for you, and whilst you can bluff knowing network security as a profession, in a similar way i have, the nuts and bolts like this are harder to bluff if anyone pays much attention to the little things.
so anyway, maybe perl is a good way to go... you can open a socket with a lot of control in perl, unlike telnet. check the client example here... http://www.perlfect.com/articles/sockets.shtml which you *could* simplify into a single perl command line.
what sort of output are you looking at? how much faster do you need it to be? I would say you'd get a very good speed up if you look at forking the requests to test everything at once, or nearly so. whilst the successful connections will complete quickly any timeout would delay things substantially, and if you have a dozen of them out of maybe 1000 devices, that'll make your script take a LOT longer without any benefit.
what sort of format are you actually looking at? i'd suggest letting a bash script just fork out the same results out of order, and then just sort the output to order the rows nicely.
What I mean by formatting is just what it looks like when the log file is produced. I would like something like:
Row 1 Row 2 Row 3 Row
ip address up/down Telnet on/off
This way they can clearly see the ip address of the NAM's and Sniffers and whether or not telnet port 23 if on or off.
I hope that clarifies it a little better. I am trying to keep this position and I see that it requires a little shell scripting knowledge and I am trying to wing it to hopefully get the position. thanks
It is going to be for about 100 devices right now
Last edited by metallica1973; 11-24-2007 at 11:33 AM.
$ cat check.ksh
printf " %-20.20s %-8s %-6s\n" host status telnet
for host in $(<list)
if ping $host 5 >/dev/null 2>&1
read foo < /dev/tcp/$host/23 && telnet=open
printf " %-20.20s %-8s %-6s\n" $host $status $telnet
host status telnet
127.0.0.1 up closed
192.168.1.1 up open
192.168.1.2 up closed
192.168.1.3 down n/a
Just an FYI. In Linux bash " foo < /dev/tcp/$host/22 && ssh=open" works as well. However, if the port is closed, as when I tried "foo < /dev/tcp/$host/23 && telnet=open" it stalls.
I tried it in ksh and it stalled as well.