ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
ilikejam, you are the biggest help but please forgive me for my extremly limited programming knowledge(I promise will study up on this stuff) but I tried to incorporate this into my little program and I cant seem to get the appropiate output, check it out!
SNIFFERS IP_Address Status Telnet =========== ================= === ====== Test1.aa.bb.ccc.edu Test1.aa.bb up closed Test2.bb.cc.ddd.edu Test2.bb.cc up closed Test3.dd.ff.ggg.edu Test3.dd.ff up closed Test5.ee.zzz.edu Test5.ee.zz up closed
I know that problem is here:
PHP Code:
IP_Address="$IP_Addr"
I need my output to look like this:
PHP Code:
SNIFFERS IP_Address Status Telnet =========== ============ ====== ====== Test1.aa.bb 192.64.150.18 up closed Test2.bb.cc 192.54.211.3 up closed Test3.dd.ff 192.29.178.11 up closed Test5.ee.zz 192.16.114.7 up closed
help
Last edited by metallica1973; 12-06-2007 at 06:36 AM.
I freakin love you man! next pay check it is done. Here is my finish product with the help of so many great individuals just to name a few(ilikejam,jiliagre,chrism01,acidkeypie,pixellany) keep up the great work.
By the way, that script still won't work - the ksh /dev/tcp/<IP>/<port> trick only works with numerical IP addresses, not hostnames, so you'll have to have
but even that doesn't work on my Solaris 10 boxes, because the read never returns when connecting to telnet hosts. Works with SSH (port 22), but not telnet.
To be honest, I'd use nmap (packages are available at sunfreeware) - it was designed to do this sort of thing.
This is the script (well, the important bit anyway) I run from cron at 6 every morning - the output is sent to my personal email to give me an early warning in case a machine has fallen over during the night.
Code:
for go in `cat $LIST`
do
/usr/local/bin/nmap -P0 -sT -p22 $go 2>&1 | egrep 'closed|filtered|Failed to resolve' > /dev/null
if [ $? == 0 ]
then
echo "$go - no ssh"
else
echo "$go - OK"
fi
done
$LIST is just a file with a list of hostnames. Most of our hosts have telnet switched off, so I use an open SSH port to tell if the machine's in something resembling a usable state. Just change '-p22' to '-p23' to test telnet instead.
If nmap's not an option, you could do something funky with a sleep->kill after the read in your script to see if the read process is waiting, and take that as a 'yes, telnet's running', but that's a disgusting hack and I feel dirty for even having thought of it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.