IP Lookup and Concatenate
#1
Posted 01 June 2012 - 05:28 PM
I'm very new to this but I love it so far. I've written a couple of really basic programs but I need to do a more complex one and I'm having some trouble with how it will work.
What I'd like to do is have the program look up the local IP Address and add that number with the last octet changed to 55 and save that to a variable.
Is this possible or does anyone have any directions I can look in?
Thanks in advance, this stuff is rad.
#2
Posted 01 June 2012 - 05:34 PM
Br,
UEZ
The own fart smells best! ✌
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯
#3
Posted 01 June 2012 - 05:39 PM
What I want to do is have the program look up the IP address of the machine and save to a var. So lets say the IP of the machine is 10.XXX.XXX.XXX, the next step is to have the program change the last number of this series to 55 so it would read 10.XXX.XXX.55.
Does that make sense?
#4
Posted 01 June 2012 - 06:02 PM
#5
Posted 01 June 2012 - 06:03 PM
$ip = @IPAddress1 $new = StringRegExpReplace($ip, "(d{1,3}.d{1,3}.d{1,3}.)d{1,3}", "${1}55") MsgBox(0, "Test", "New IP: "& $new)
Br,
UEZ
The own fart smells best! ✌
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯
#6
Posted 01 June 2012 - 06:49 PM
This will be used to add network printers at different locations.
Thanks for your help UEZ, I'm pretty psyched about using this.
#7
Posted 01 June 2012 - 07:16 PM
$ip = @IPAddress1 $new = StringLeft($ip, StringInStr($ip, ".", 0, -1)) & "55" MsgBox(0, "Test", "New IP: "& $new)
Br,
UEZ
The own fart smells best! ✌
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯
#8
Posted 01 June 2012 - 08:05 PM
How did you find these things you are showing me?
#9
Posted 01 June 2012 - 08:08 PM
Your addition is working perfectly but DOS is telling me "INVALID PARAMETER", I'll keep plugging away.
How did you find these things you are showing me?
Practical knowledge.
Br,
UEZ
The own fart smells best! ✌
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯
#10
Posted 01 June 2012 - 08:16 PM
Thanks again for your help
#11
Posted 01 June 2012 - 09:17 PM
Local $sIPAddress = @IPAddress1 Local $sReturn = StringRegExpReplace($sIPAddress, '((d{1,3}.){3})d{1,3}', '${1}55') MsgBox(4096, '', $sReturn & @CRLF)
Edit: Also just to show that there are more ways to achieve the same goal here is using the native AutoIt functions (though UEZ's is way more efficient! Hint: he doesn't use StringLen, therefore one less function call.)
Local $sIPAddress = @IPAddress1 Local $sReturn = StringTrimRight($sIPAddress, StringLen($sIPAddress) - StringInStr($sIPAddress, ".", 0, -1)) & "55" MsgBox(4096, '', $sReturn & @CRLF)
Edited by guinness, 01 June 2012 - 09:36 PM.
- Robonglious likes this
Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _DesktopDimensions() • _DisplayPassword() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringIsValid() • _StringReplaceWholeWord() • _StringStripChar() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • AutoIt Search • AutoIt3 Portable • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasteBin • SciTE Jump • Signature Creator • WM_COPYDATA • More Examples...Updated: 11/04/2013
#12
Posted 04 June 2012 - 03:41 PM
I'm sure I just don't understand how this is working.
Thanks for your help
#13
Posted 04 June 2012 - 04:04 PM
StringInStr() is telling the position of the last "."
So StringLen() - StringInStr() gives the number of chars to trim from the right.
Then concat 55
- Robonglious likes this
Run('hh mk:@MSITStore:'&StringReplace(@AutoItExe,'.exe','.chm')&'::/html/tutorials/helloworld/helloworld.htm','',@SW_MAXIMIZE)
#14
Posted 04 June 2012 - 04:42 PM
#16
Posted 04 June 2012 - 09:57 PM
Edited by guinness, 04 June 2012 - 09:59 PM.
Example List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _DesktopDimensions() • _DisplayPassword() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringIsValid() • _StringReplaceWholeWord() • _StringStripChar() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • AutoIt Search • AutoIt3 Portable • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • FileInstallr • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIGetBkColor() • LockFile() • PasteBin • SciTE Jump • Signature Creator • WM_COPYDATA • More Examples...Updated: 11/04/2013
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users





