Sign in to follow this  
Followers 0
RAMzor

Network

9 posts in this topic

Hello All!

I will start my script after that network cable is plugged.

How can i know if network cable is plugged or unplugged?

Share this post


Link to post
Share on other sites



Hello All!

I will start my script after that network cable is plugged.

How can i know if network cable is plugged or unplugged?

use netsh to check network connection, or you could even just run ipconfig/all>whatever.txt and go through that to check.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Do you want somthing to trigger your script or do you want to know if the network is down?

From the help file:

Ping ( address or hostname [, timeout] )

Share this post


Link to post
Share on other sites

I want identify network connection to trigger my script :"> But I dont have the IP adderss and tcpip - only MAC address (Physical Address like F0-FF-FF-00-00-01).

This is fiber network card from 3Com installed on Win2k (tester PC) and I want automaticaly run a test program for the connected device as I connect the divice to the PC (fiber optic network connection). :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Check out the _GetIPConfigData() UDF in my sig.

#)

EDIT: If the IP address is something invalid, like 0.0.0.0, the network should be down.

If that network connection is the only one on the PC, ping 255.255.255.255. If you get a reply, the network is up.

(This works because 255.255.255.255 is a limited broadcast address)

Edited by nfwu

Share this post


Link to post
Share on other sites

No idea? :think:

Share this post


Link to post
Share on other sites

No idea? :think:

few ways to go. depending on your operating system, you can do a :

ipconfig/all > ipinfo.txt

then parse the file for the device with that mac id

netsh would work too, same kind of thing, google for netsh and you can get all the switches and usage details, then use it to pipe info for that connection out to a text file the same way. then you'll be able to see all of the details, as far as ip address, state (i think), etc.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Here's a method I used last night for a similar problem

(Thanks to Larry & Trids)

$ChecK_It = IsAlive()
If StringInStr($ChecK_It, "Not Connected") OR StringInStr($ChecK_It, "OffLine") Then
Whatever routine you want to use
EndIf

Func Is_Alive()
   Ping('www.google.com',3000)
   $Internet_Connection_Modem = 0x1
   $Internet_Connection_Lan = 0x2
   $Internet_Connection_Proxy = 0x4
   $Internet_Connection_Modem_Busy = 0x8
   $Internet_Ras_Installed = 0x10
   $Internet_Connection_Offline = 0x20
   $Internet_Connection_Configured = 0x40
   $Ret = DllCall ("WinInet.dll", "int", "InternetGetConnectedState", "int_ptr", 0, "int", 0)
   If $Ret[0] then
    ;check type of connection
      $Sx = ""
      If BitAND ($Ret[1], $Internet_Connection_Modem) Then $Sx = $Sx & "MODEM" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Lan) Then $Sx = $Sx & "LAN" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Proxy) Then $Sx = $Sx & "PROXY" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Modem_Busy) Then $Sx = $Sx & "MODEM_BUSY" & @LF
      If BitAND ($Ret[1], $Internet_Ras_Installed) Then $Sx = $Sx & "RAS_INSTALLED" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Offline) Then $Sx = $Sx & "OFFLINE" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Configured) Then $Sx = $Sx & "CONFIGURED" & @LF
   Else
      $Sx = "Not Connected"
   Endif
   Return $Sx
EndFunc ;<==> Is_Alive()

The Ping was added only because my wireless likes to go to sleep every now and then so running the ping (even if it doesn't resolve) gets the wireless kick started so that the rest of the check is accurate. The ping alone won't really tell me if I'm connected or not. The rest of the Func does.

*** EDITED because I started the code at the wrong point :think:

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

C:\Documents and Settings\Owner>ipconfig /all

Windows IP Configuration

        Host Name . . . . . . . . . . . . : fake_host_name
        Primary Dns Suffix  . . . . . . . :
        Node Type . . . . . . . . . . . . : Mixed
        IP Routing Enabled. . . . . . . . : No
        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:

        Media State . . . . . . . . . . . : Media disconnected
        Description . . . . . . . . . . . : Realtek RTL8139/810x Family Fast Eth
ernet NIC
        Physical Address. . . . . . . . . : FF-FF-FF-FF-FF-FF

C:\Documents and Settings\Owner>ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection:

        Media State . . . . . . . . . . . : Media disconnected

C:\Documents and Settings\Owner>

Shows that ipconfig prints "Media disconnected" when the cable is unplugged.

NOTE: Host name and Physical Addresses have been removed. (FF-FF-FF-FF-FF-FF is the physical address for a limited broadcast)

#)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0