I will give it a shot. thanks
|
That work fine for one string but this is a standard nslookup for our domain:
PHP Code:
PHP Code:
thanks |
Quick and dirty:
Code:
nslookup S00CBBF.aa.bb.ccc.edu | grep '^Name:' | awk '{print $2}' | awk -F'.' '{for (i=1;i<=NF-2;i++) {if (i<NF-2) printf $i"."; else print $i}}' |
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!
PHP Code:
PHP Code:
I know that problem is here: PHP Code:
PHP Code:
help |
Code:
nslookup S00CBBF.aa.bb.ccc.edu | nawk 'BEGIN{FS=":"} |
that is another way of doing it but I still have problems with the variables in my script and I think that it is the :
PHP Code:
|
Easy now.
I think you've just mixed up your variables. Try the following: Code:
#!/bin/ksh Edit: I'm assuming the snifflist is a list of fully qualified hostnames, not IP addresses. |
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.
PHP Code:
|
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
Code:
IP_Addr="$(nslookup $SNIFFERS | tail -3 | grep '^Address:' | awk '{print $2}')" Code:
read foo < /dev/tcp/$SNIFFERS/23 2>/dev/null && Telnet=open |
Do not ask me why but the scipts works. I am testing it now and it validity. I will get back to you shortly!
|
I'm betting one of two things will happen - either the script will always show the telnet connection as closed, or it won't return.
Dave |
It seems to be working, try it out.
|
Your telnet server(s) must print a line before the login prompt for 'read' to return. None of our do, so read just sits there waiting for a newline.
But hey, whatever works... Dave |
You are right. when it finds an open telnet session/port 23 it hangs. what to do!
|
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` 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. Dave |
All times are GMT -5. The time now is 04:54 AM. |