Jump to content

Scripting help for DNS-O-Matic, plz!


Recommended Posts

I connect to internet using dial up. I use autoit script for this. What I wanted to add up is as follows:

1. After getting connected I should be able to connect to dnsomatic.com and update my new ip.

2. Capture the new IP using http://dynupdate.no-ip.com/ip.php which i will be able to store in a log file or email it.

3. During the above process I would prefer if no IE window to open up.

Can this be done?

Plz help guys!

Link to comment
Share on other sites

I connect to internet using dial up. I use autoit script for this. What I wanted to add up is as follows:

1. After getting connected I should be able to connect to dnsomatic.com and update my new ip.

2. Capture the new IP using http://dynupdate.no-ip.com/ip.php which i will be able to store in a log file or email it.

3. During the above process I would prefer if no IE window to open up.

Can this be done?

Plz help guys!

Look at the _IE* functions of the IE.au3 UDF. Everything there works with IE whether visible or not.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

It should work without IE but with InetRead from the new Beta: Documentation of the API

;#BETA
; set the required user agent (change it to your client-info)
HttpSetUserAgent("Company - Device - Version Number")

; get current IP
$currentIP = BinaryToString(InetRead("http://myip.dnsomatic.com/",1))

; send the request. result code is described on API page
; insert you data for the placeholders
$result = InetRead("https://username:password@updates.dnsomatic.com/nic/update?hostname=yourhostname&myip=ipaddress&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG",1)
If Not @error Then
   $result = BinaryToString($result)
EndIf
Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

hi ProgAndy i am getting this error! do i need to include something?

..\UpdateIP.au3(3,61) : ERROR: HttpSetUserAgent(): undefined function.
HttpSetUserAgent("MyScript - QuickUpDateOnReconnect - 0.0.1")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
..\UpdateIP.au3(6,68) : ERROR: InetRead(): undefined function.
$currentIP = BinaryToString(InetRead("http://myip.dnsomatic.com/",1)
Edited by njscorpion
Link to comment
Share on other sites

hi ProgAndy i am getting this error! do i need to include something?

..\UpdateIP.au3(3,61) : ERROR: HttpSetUserAgent(): undefined function.
HttpSetUserAgent("MyScript - QuickUpDateOnReconnect - 0.0.1")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
..\UpdateIP.au3(6,68) : ERROR: InetRead(): undefined function.
$currentIP = BinaryToString(InetRead("http://myip.dnsomatic.com/",1)
Are you running it with 3.2.1.1 3.3.1.0 Beta minimum (i.e. Alt-F5 in SciTE)?

:D

Edit: Wrong minimum version fixed.

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

OK! now i am facing a new problem, i found Jos's SMTP mailer script and added it to ProgAndy's provided code, i made few minor changes to it but those changes should not be effecting the execution. when i am executing the code its working just fine, as it is supposed to, but after i am beta compiling (F7) , when i am executing it its giving me "Autoit Error: Line -1: Error:Unknown function name." I don't know what i am doing wrong plz have a look!

#include<file.au3>

$SmtpServer = "mysmtp"; address for the smtp-server to use - REQUIRED
$FromName = "MyName"; name from who the email was sent
$FromAddress = "from@email.com"; address from where the mail should come
$ToAddress = "to@email.com"; destination address of the email - REQUIRED
$CcAddress = ""; address for cc - leave blank if not needed
$BccAddress = ""; address for bcc - leave blank if not needed
$Importance = "High"; Send message priority: "High", "Normal", "Low"
$Username = "myusername"; username for the account used from where the mail gets sent - REQUIRED
$Password = "mypass"; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 25; port used for sending the mail
$ssl = 1; enables/disables secure socket layer sending - put to 1 if using httpS

RunWait(@ComSpec & " /c " & 'ipconfig/all >c:\ip.txt', "", @SW_HIDE)
$Time = FileGetTime("c:\ip.txt", 1, 1)

HttpSetUserAgent("MyScript - QuickUpDateOnReconnect - 0.0.1")
$currentIP = BinaryToString(InetRead("http://myip.dnsomatic.com/", 1))
$Subject = "Updated IP At: " & $Time & " New IP = " & $currentIP; subject from the email - can be anything you want it to be
$Body = "New File Created At: " & $Time; the messagebody from the mail - can be left blank but then you get a blank mail
$AttachFiles = "c:\ip.txt"; the file you want to attach- leave blank if not needed

$result = InetRead("https://username:pass@updates.dnsomatic.com/nic/update?hostname=all.dnsomatic.com&myip=" & $currentIP & "&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG", 1)
If Not @error Then
    $result = BinaryToString($result)
EndIf

Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl)
If @error Then
    MsgBox(0, "Error sending message", "Error code:" & @error & "  Description:" & $rc, 5)
EndIf
;
; The UDF
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance = "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0)
    Local $objEmail = ObjCreate("CDO.Message")
    $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
    $objEmail.To = $s_ToAddress
    Local $i_Error = 0
    Local $i_Error_desciption = ""
    If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
    If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
    $objEmail.Subject = $s_Subject
    If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
        $objEmail.HTMLBody = $as_Body
    Else
        $objEmail.Textbody = $as_Body & @CRLF
    EndIf
    If $s_AttachFiles <> "" Then
        Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
            ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF);### Debug Console
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment($S_Files2Attach[$x])
            Else
                ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF)
                SetError(1)
                Return 0
            EndIf
        Next
    EndIf
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
    If Number($IPPort) = 0 Then $IPPort = 25
    $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
;Authenticated SMTP
    If $s_Username <> "" Then
        $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
        $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
    EndIf
    If $ssl Then
        $objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
    EndIf
;Update settings
    $objEmail.Configuration.Fields.Update
; Set Email Importance
    Switch $s_Importance
        Case "High"
            $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "High"
        Case "Normal"
            $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Normal"
        Case "Low"
            $objEmail.Fields.Item("urn:schemas:mailheader:Importance") = "Low"
    EndSwitch
    $objEmail.Fields.Update
; Sent the Message
    $objEmail.Send
    If @error Then
        SetError(2)
        Return $oMyRet[1]
    EndIf
    $objEmail = ""
EndFunc  ;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    $oMyRet[0] = $HexNumber
    $oMyRet[1] = StringStripWS($oMyError.description, 3)
    ConsoleWrite("### COM Error !  Number: " & $HexNumber & "   ScriptLine: " & $oMyError.scriptline & "   Description:" & $oMyRet[1] & @LF)
    SetError(1); something to check for when this function returns
    Return
EndFunc  ;==>MyErrFunc
FileDelete("c:\ip.txt")
Edited by njscorpion
Link to comment
Share on other sites

OK! now i am facing a new problem, i found Jos's SMTP mailer script and added it to ProgAndy's provided code, i made few minor changes to it but those changes should not be effecting the execution. when i am executing the code its working just fine, as it is supposed to, but after i am beta compiling (F7) , when i am executing it its giving me "Autoit Error: Line -1: Error:Unknown function name." I don't know what i am doing wrong plz have a look!

Do you mean you ran it under Beta 3.3.1.1 in SciTE (alt-F5)? Did you get anything in the SciTE console that way?

Earlier, you said you "needed to Switch-Definitions". Exactly what did you do?

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

sorry, i did Beta compile(alt+F7) not F7

SciTE console with alt+F5

>"C:\Program Files(x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "C:\Documents and Settings\username\Desktop\IpReporter_Beta.au3" /autoit3dir "C:\Program Files(x86)\AutoIt3\beta" /UserParams  
+>23:47:53 Starting AutoIt3Wrapper v.2.0.0.1    Environment(Language:0409  Keyboard:00000409  OS:WIN_XP/Service Pack 2  CPU:X64 OS:X64)
>Running AU3Check (1.54.16.0)  from:C:\Program Files(x86)\AutoIt3\beta
+>23:47:53 AU3Check ended.rc:0
>Running:(3.3.1.1):C:\Program Files(x86)\AutoIt3\beta\autoit3_x64.exe "C:\Documents and Settings\username\Desktop\IpReporter_Beta.au3"  
@@ Debug(62) : $S_Files2Attach = 
>Error code: 0
+>23:48:05 AutoIT3.exe ended.rc:0
+>23:48:06 AutoIt3Wrapper Finished
>Exit code: 0   Time: 14.077

Switch-Definitions: i used the tool "C:\Program Files(x86)\AutoIt3\SciTE\Defs\UpdateDefs.exe" which i was wrong about.

Edited by njscorpion
Link to comment
Share on other sites

  • Developers

The compiled version is using the UNICODE Bin file. Running the script uses the X64 AUtoIt3.exe.

Could that be the difference?

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

hey! Jos i compiled it using Aut2exe without x64 still the genrated output is giveing the same error! guys plz help :)

Have you tried to compile with x64?

Add #AutoIt3Wrapper_UseX64 to the top of the script source.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

Could it be you have have some mixed versions in the directory: C:\Program Files(x86)\AutoIt3\beta ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Could it be you have have some mixed versions in the directory: C:\Program Files(x86)\AutoIt3\beta ?

uninstalled all

reinstalled Autoit 3.2.0.0

reinstalled Autoit 3.3.1.1

still the same, the only thing i was able to sort out is the problem is not in Jos's email code but it has some thing to do with ProgAndy piece of code.

when i created a new file UpdateIP.au3 the content:

;#BETA
; set the required user agent (change it to your client-info)
HttpSetUserAgent("MyScript - QuickUpDateOnReconnect - 0.0.1")

; get current IP
$currentIP = BinaryToString(InetRead("http://myip.dnsomatic.com/",1))

; send the request. result code is described on API page
; insert you data for the placeholders
$result = InetRead("https://User:Pass@updates.dnsomatic.com/nic/update?hostname=all.dnsomatic.com&myip="&$currentIP&"&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG",1)
If Not @error Then
   $result = BinaryToString($result)
EndIf
Edited by njscorpion
Link to comment
Share on other sites

i was wrong again!

guys this look mostly like BUG (i am no expert, need expert opinion),is it a bug?

code :

#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Version=beta

#include<INet.au3>
HttpSetUserAgent("MyScript - QuickUpDateOnReconnect - 0.0.1")
MsgBox(0,"Step 1:","HttpSetUserAgent Set")
$currentIP = _GetIP()
MsgBox(0,"Step 2:","Got New IP"&$currentIP)
$result = InetRead("https://User:Pass@updates.dnsomatic.com/nic/update?hostname=all.dnsomatic.com&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG",1)
MsgBox(0,"Step 3:","Update Send"& BinaryToString($result))
If Not @error Then
        $result = BinaryToString($result)
EndIf
sleep(10000)
ExitoÝ÷ Ú'â®éÀßæ+Z±«®*mÛw½êò¶§
+È+y«[ºÜ!zx¢jbà%·á{Ö§uì^rë^¶Åè­+Þ²Ø^±©zºè­¨v§u¨p%·á{¢ëiºÖ®¶­sbgV÷C´3¢b3#µ&öw&ÒfÆW2bb3#´WFôC2b3#µ66DRb3#´WFôC5w&W"b3#´WFôC5w&W"æWRgV÷C²ö&WFöâgV÷C´C¢b3#µWFFTDå4ôÖF2æS2gV÷C²öWFöC6F"gV÷C´3¢b3#µ&öw&ÒfÆW2bb3#´WFôC2b3#¶&WFgV÷C°¢²fwC³#£S£Sb7F'FærWFôC5w&W"bã"ãããVçf&öæÖVçBÆæwVvS£C¶W&ö&C£Cõ3¥tåõõ6W'f6R6²"5S¥cBõ3¥cB¢fwCµ'VææærS46V6²ãSBãbãg&öÓ¤3¢b3#µ&öw&ÒfÆW2bb3#´WFôC2b3#¶&WF¢²fwC³#£S£SbS46V6²VæFVBç&3£¢²fwC²WFFVB%EõdU%4ôâæf÷&ÖFöâà¢fwC³#£S£Sb&W6÷W&6RWFFærfæ6VBà¢fwCµ'Væææs¢2ã2ãã¤3¢b3#µ&öw&ÒfÆW2bb3#´WFôC2b3#¶&WFb3#¶WC&WRb3#¶WC&WU÷cBæWRöâgV÷C´C¢b3#µWFFTDå4ôÖF2æS2gV÷C²ö÷WBgV÷C´C¢b3#µWFFTDå4ôÖF2æWRgV÷C²ö6ö×Böæ÷6²ô&â3¢b3#´Dô5TÔWãb3#´Äô4Å7ãb3#µFV×b3#´UDôGãä$ࢲfwC³#£S£SrWC&WRæWRVæFVBç&3£¢²fwC³#£S£Sr7&VFVB&öw&Ó¤C¢b3#µWFFTDå4ôÖF2æWP¢ÒfwCµv&ææs¢F22âcB6ö×ÆVB67&BæBvÆÂöæÇv÷&²öâ77FVÒvFcBõ2à¢fwCµWFFVBFR6÷W&6RfW'6öâFó£ããã"ââࢲfwC³#£S£SWFôC5w&W"fæ6V@¢fwC´WB6öFS¢FÖS¢ã3
Edited by njscorpion
Link to comment
Share on other sites

It seems that the bin-File in the beta-version is not updated to the new one.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...