Page 1 of 2 12>
Topic Options
#36736 - 2003-02-20 11:56 AM Monitor Connectivity on My Own Network ?
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Can anyone help !?? I need to set up a script to notify me by sound when a user connects onto my network. I was thinking as soon as there address starts to ping, a sound notifcation can let me know ? Is this possible, ive tried several things but just cant seem to do it......
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#36737 - 2003-02-21 12:30 AM Re: Monitor Connectivity on My Own Network ?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Here is a script that will do it for you:
code:
Break ON

$sIPAddress="a.b.c.d"

While "true"
Shell '%COMSPEC% /C ping -n 1 ' + $sIPAddress + ' | find "TTL=" >/dev/null'
If @ERROR=0
$Null=MessageBox("IP Address " + $sIPAddress + " is responding","It's Alive!")
Exit 0
EndIf
Sleep(60)
Loop

Set $sIPAddress to the address you want to monitor.

This will check every 60 seconds, and popup a window when the IP address responds then exit.

Change the MessageBox() to "Beep" or "Play" to have a sound instead.

Top
#36738 - 2003-02-21 12:47 AM Re: Monitor Connectivity on My Own Network ?
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Could work, but what if DHCP???

Why not use "net send" in the login script to send a msg to "your-workstation | your-userid"?
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#36739 - 2003-02-20 02:23 PM Re: Monitor Connectivity on My Own Network ?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
quote:
I was thinking as soon as there address starts to ping
I assumed from this means he knows the IP address.

Net send from the login script is ok, however if the user in question doesn't log in of course there is no login script to put it in.

If the client uses DHCP there are two options
1) If he has a modern DHCP/DNS combination the leased address will be added via DDNS update, so he can ping via the host name instead.
2) If a cranky old NT4.0 solution switch on logging and simply poll todays log file waiting for the lease to appear.

The other problem with using login scripts or polling the DHCP log file is that it won't tell you if the PC is already there.

Top
#36740 - 2003-02-20 02:24 PM Re: Monitor Connectivity on My Own Network ?
Radimus Moderator Offline
Moderator
*****

Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
look for kpinger on my kix site...
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#36741 - 2003-02-20 02:25 PM Re: Monitor Connectivity on My Own Network ?
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
You could also use Ping() UDF and ping the computer name which would use whatever resolution service you are running.. but I think that I like the idea of doing it in loginscript and combining with postie.exe to send you an email in that case of the desired computer logging in.. or if one of multiple computers logs in.. something like.

code:
 
$TO = you@company.com
$FROM = you@company.com
$SUB = "Login Alert From @WKSTA By @USERID"
$IMP = "high"
$MSG = "User: @USERID has logged into workstation: @WKSTA."

if @WKSTA = "COMPUTER1" OR @WKSTA = "COMPUTER2"
$ShellString='@ScriptDir\postie.exe -host:smtp.company.com -to:$TO -from:$FROM -replyto:$FROM -s:"$SUB" -msg:"$MSG" -$IMP'
Shell $ShellString
endif

_________________________
Austin Henderson

Top
#36742 - 2003-02-20 02:27 PM Re: Monitor Connectivity on My Own Network ?
Austin Offline
Seasoned Scripter

Registered: 2002-01-24
Posts: 439
Have the machine run a startup script that send an email is also an option if we are worried about the machine not actually logging into a network.
_________________________
Austin Henderson

Top
#36743 - 2003-02-20 02:51 PM Re: Monitor Connectivity on My Own Network ?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
As you can see from all the replies, what you can do rather depends on how much control you have over the machines in question.

If you provide more information about what you are trying to achieve we will be able to give you a more suitable solution.

Include the operating system revisions in any update as well.

Top
#36744 - 2003-02-20 03:14 PM Re: Monitor Connectivity on My Own Network ?
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
The machine is using DHCP (sorry forgot to say) but is also using DNS - which i know. Can i therefore use the name instead of the ip address ?

Ideally sound would be needed as if im away from my pc I can hear a sound and be alerted to fact the machine is loggin onto the network.
The OS on the machine is NT 4 but i am using 2000.

Any suggestions would be great..
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#36745 - 2003-02-20 03:57 PM Re: Monitor Connectivity on My Own Network ?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Sure, instead of an IP address just use the host name.

As I said in the post with the script change the messagebox alert to "beep" or use "play" to play a ".wav" file if you want a sound alert.

If you want a continuous alert (every 60 seconds) remove the "Exit 0", otherwise the script will exit after the first alert.

Top
#36746 - 2003-02-20 05:08 PM Re: Monitor Connectivity on My Own Network ?
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Cheers I'll let you know how it goes
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#36747 - 2003-02-20 05:40 PM Re: Monitor Connectivity on My Own Network ?
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Ive just tried it on a pc i know thats on the network but its coming up with "the system cannot find the path specfied"

Have i dont it right below ?

Break on
176.4.16.23="a.b.c.d"
While "true"
Shell '%COMSPEC% /C ping -n 1 ' + 176.4.16.23 + ' | find "TTL=" >/dev/null'
If @ERROR=0
$Null=MessageBox("IP Address" + 176.4.16.23 + " is respondin","It's Alive!")
Exit 0
EndIf
Sleep(60)
Loop

Sorry im kinda new to this!!
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#36748 - 2003-02-20 05:45 PM Re: Monitor Connectivity on My Own Network ?
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
This is definitely incorrect: 176.4.16.23="a.b.c.d"

Adn this will put you into a continous loop: While "true"
_________________________
There are two types of vessels, submarines and targets.

Top
#36749 - 2003-02-21 10:11 AM Re: Monitor Connectivity on My Own Network ?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Ok, if the IP address you are looking for is 176.4.16.23 your script should look like this:
code:
Break ON
$sIPAddress="176.4.16.23"
While "true"
Shell '%COMSPEC% /C ping -n 1 ' + $sIPAddress + ' | find "TTL=" >/dev/null'
If @ERROR=0
$Null=MessageBox("IP Address " + $sIPAddress + " is responding","It's Alive!")
Exit 0
EndIf
Sleep(60)
Loop

If you know the host name it will look like this (assuming the host is called "thehost.acme.com):
code:
Break ON
$sIPAddress="thehost.acme.com"
While "true"
Shell '%COMSPEC% /C ping -n 1 ' + $sIPAddress + ' | find "TTL=" >/dev/null'
If @ERROR=0
$Null=MessageBox("IP Address " + $sIPAddress + " is responding","It's Alive!")
Exit 0
EndIf
Sleep(60)
Loop

quote:
Adn this will put you into a continous loop: While "true"
It's supposed to [Smile]

The "Exit 0" will exit the script once the ping succeeds, so the alert will only appear once. If the "Exit 0" is removed, the script will message (or beep or whatever) every 60 seconds.

AzzerShaw, the error you are getting probably means one of three things:
1) You don't have "ping" in your PATH
2) You don't have "find" in your PATH
3) You don't have %COMSPEC% set correctly

Top
#36750 - 2003-02-21 10:24 AM Re: Monitor Connectivity on My Own Network ?
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Azzershaw,

how many machines do you wish to monitor???

[ 21. February 2003, 10:24: Message edited by: MightyR1 ]
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#36751 - 2003-02-21 10:48 AM Re: Monitor Connectivity on My Own Network ?
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
Morning Boys

Ive slightly modified it, so I can see exactly what it is doing ("I like simple things [Smile] ")

Break on
$Null=""
$sIPAddress="ipaddress"
While "true"
Shell "C:\WINNT\SYSTEM32\CMD.EXE /C ping -n 1 ipaddress"
If @ERROR=0
$Null=MessageBox("IP Address" + $sIPAddress + " is respondin", PLAY "v:\asterix.wav")
Exit 0
EndIf
Sleep(60)
Loop

AND IT WORKS !!
But im now having trouble playing the sound, now coming up with an error "expected error" Any ideas guys ?

It will be for mutilple pcs but I only want to check one at a time
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
#36752 - 2003-02-21 11:07 AM Re: Monitor Connectivity on My Own Network ?
MightyR1 Offline
MM club member
*****

Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
Try this:
code:
Break on 
$Null=""
$sIPAddress="ipaddress"
While "true"
Shell "%comspec% /C ping -n 1 ipaddress"
If @ERROR=0
$Null=MessageBox("IP Address" + $sIPAddress + " is responding!", "Your box title")
PLAY "v:\asterix.wav"
Exit 0
EndIf
Sleep(60)
Loop

Not sure how you'd like to implement this... Multiple nodes to check - change the kix manually each time???

May we know what you're doing???
_________________________
Greetz,
Patrick Rutten

- We'll either find a way or make one...
- Knowledge is power; knowing how to find it is more powerful...
- Problems don't exist; they are challenges...

Top
#36753 - 2003-02-21 11:11 AM Re: Monitor Connectivity on My Own Network ?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
You want to swap the order so that it runs:
code:
PLAY "v:\asterix.wav"
$Null=MessageBox("IP Address" + $sIPAddress + " is responding!", "Your box title")

Otherwise the sound won't play until you've confirmed the dialogue prompt.

[ 21. February 2003, 11:12: Message edited by: Richard H. ]

Top
#36754 - 2003-02-21 11:44 AM Re: Monitor Connectivity on My Own Network ?
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Ok, lots of enhancements:
code:
Updated code in later post

Change the value for $sSound to the path to your sound file.
Change the values for $sAddressList to all the host names or IP addresses you want to monitor.

When you run the script it will check every $iInterval seconds for the hosts. If it finds any it will
1) Play your sound
2) Display a list of all the machines which responded on the console with the time.
3) Pop-up the same message in a message-box, which will stay on screen for 5 seconds.

[ 21. February 2003, 12:45: Message edited by: Richard H. ]

Top
#36755 - 2003-02-22 12:10 AM Re: Monitor Connectivity on My Own Network ?
AzzerShaw Offline
Seasoned Scripter
****

Registered: 2003-02-20
Posts: 510
Loc: Cheltenham, England
It works purfect !!! Thanks for your time guys
_________________________
If at first you don't succeed, try again. Then quit. There's no use being a damn fool about it. - W.C Fields

Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 702 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.073 seconds in which 0.023 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org