|
|
|||||||
All, First post so bear with me. I'm trying to use kix as a wrapper to robocopy, but I need a way to work out what connection is being utilized. We want these to run without user interaction, so need a way for kix running on the users laptop to detect weather they are on a VPN link, or the local LAN, or their T Mobile wireless card. Any Ideas? Joel |
||||||||
|
|
|||||||
well, do you have ip range set for vpn clients? if you have, you can test against that ip-range with @ipAddress0, @ipAddress1, @ipAddress2 and @ipAddress3 |
||||||||
|
|
|||||||
The way I've decided to look at it, is to use a 4 packet ping to their local server. Taking the average response time and averaging it, and if its under 100ms than start the backup. Any ideas how I'd even start doing that? Joel |
||||||||
|
|
|||||||
Well I don't think that is a very solid method for determining connection speed. But if you want to do it then you'd probably need to use FIND to locate the data and then put it together and perform the math on it. A bit late for me here but if you need Silver Platter code then you'll need to ask and see if someone can help you further this morning as I'm about to get to bed now. |
||||||||
|
|
|||||||
This might work for you: Code: $sServerIP="10.10.0.1" $iMaxHops=5 $iWait=1000 If IPIsClose($sServerIP,$iMaxHops) "Server "+$sServerIP+" is within "+$iMaxHops+" hops."+@CRLF Else "Server "+$sServerIP+" is down or too far away"+@CRLF EndIf Function IPIsClose($sIP,Optional $iHops, Optional $iWait) If VAL($iHops)<1 $iHops=30 EndIf If VAL($iWait)<1 $iWait=1000 EndIf SHELL %COMSPEC%+" /C tracert -d -h "+$iHops+" -w "+$iWait+" "+$sIP+' | FIND "ms '+$sIP+'" >NUL:' $IPIsClose=Not @ERROR Exit @ERROR EndFunction Basically you use tracert to determine if the IP address is within a number of hops. An alternative is to do a tracert, capture the output, then check the three RTTs on the last line if it matches the server IP address. Look up the PIPE udfs if you want to use this method. |
||||||||
|
|
|||||||
Code: break ON cls ;Home server Subnet $baseIP = "10.203.4" DIM $IP $check = 0 $username = "joel.cant" $backuplocation = "H:\" $IP = Join(Split(@IPADDRESS0," "),'') If Instr($IP,$baseIP) $check = 1 else $IP = Join(Split(@IPADDRESS1," "),'') If Instr($IP,$baseIP) $check = 1 else $IP = Join(Split(@IPADDRESS2," "),'') If Instr($IP,$baseIP) $check = 1 else $IP = Join(Split(@IPADDRESS3," "),'') If Instr($IP,$baseIP) $check = 1 else $check = 0 endif endif endif endif if ($check = 1) ? "Run Backup" ? "Backup Will run when you strike a key" get $x ;RUN 'c:\robocopy "c:\documents and settings\$username\My Documents" H:\$backuplocation /MIR /R:5 /W:10' exit else exit endif On better thinking I've come up with that. How do I escape the run command to allow the variables to be seen in the command line. Thanks Joel |
||||||||
|
|
|||||||
How about this: Code: Break ON CLS ;Home server Subnet $baseIP = "10.203.4" $backuplocation = "H:\" $IPLIST = Join(Split("|"+@IPADDRESS0+"|"+@IPADDRESS1+"|"+@IPADDRESS2+"|"+@IPADDRESS3," "),'') If Instr($IPLIST,"|"+$baseIP+".") "Run Backup"+@CRLF "Backup Will run when you strike a key"+@CRLF Get $x SHELL 'c:\robocopy "'+%USERPROFILE%+'" "'+$backuplocation+'" /MIR /R:5 /W:10' EndIf |
||||||||
|
|
|||||||
;RUN 'c:\robocopy "c:\documents and settings\$username\My Documents" H:\$backuplocation /MIR /R:5 /W:10' Never hard code the username in the path. Either use %userprofile% or pull it from the reg. Don't embed vars in strings. Concatenate! |
||||||||
|
|
|||||||
Cheers for the input guys One last question, how do I grab executed command output and trim it down $sIP = "10.203.1.51" $stringPing = RUN "ping /n 4 "$sIP $splitstring = Split($stringPing,"Average = ") I want just the number from the ms part of a ping command. Joel |
||||||||
|
|
|||||||
I don't understand what you are after but the following is not right. Code: $stringPing = RUN "ping /n 4 "$sIP |
||||||||
|
|
|||||||
Do a search in the UDF Library for WSHPipe. Make sure to change the search dates to the past couple of years. |
||||||||
|
|
|||||||
You might also use the wmiPing UDF. |
||||||||
|
|
|||||||
Yes, but don't forget. Quote: DEPENDENCIES: ; Windows XP or Server 2003 ; |