Jump to content

Recommended Posts

Posted

Hello dear friends,

     I hope that you can help me to complete a script in order to monitor a txt file for some wrods and if exists it will send a mail.

I've used this script but i think that i've made some errors on it. So help please

 

#include <INet.au3>
$TextFileName = "C:UsersX2ZDesktopyoussefAdentechSurvey_Monitor_Close_Control_130Survey Monitor Close Control 1.30Log.txt"
$s_SmtpServer = "smtp server"
$s_FromName = "my name"
$s_Password = "my pass"
$s_FromAddress = "my email"
$s_ToAddress = "email client"
$s_Subject = "subject"
Dim $as_Body[2]
$as_Body[0] = "Alert"
$as_Body[1] = "Defaut"
; First we read the text file
$Log = FileRead($TextFileName)
; Put the contents into an array
$pageArray = StringSplit($Log, @CRLF)
; Now go through the array and look for the word failure if its found send and email
For $i = 1 To $pageArray[0]
If StringInStr($pageArray[$i], $findtext) Then $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @computername, -1)

 

I hope to know too which field i must change

Thank you all

Best regards

Posted

Where are you having troubles in your script? It could be do to with the @ComputerName param which could have to be "EHLO " & @ComputerName. But using MsgBox's to find errors in your script is going to be invaluable for finding out what the error you are having is. ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted (edited)

Welcome to AutoIt and the forum!

If you think you have made an error how do you know?

Do you get an error? Wrong result? Anything else ...?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Where are you having troubles in your script? It could be do to with the @ComputerName param which could have to be "EHLO " & @ComputerName. But using MsgBox's to find errors in your script is going to be invaluable for finding out what the error you are having is. ;)

Hello dear friend

   First i thank you really for your quick reply, i have an error message when running the script and this it :

https://drive.google.com/file/d/0Bzzea_qkHks2eHREdXJfY3Vxa00/view?usp=sharing

For your remarque about the error type, i would specify it like  "error in heat" or something like that it will be specific word

 

Thank you again

Posted

Welcome to AutoIt and the forum!

If you think you have mad an error how do you know?

Do you get an error? Wrong result? Anything else ...?

Thank you for your reply Water

   i've attached an image for my error

Best regards

Posted

Hello

My error message is :

 

 

Line 18 (File "C:Users_X2Z.............)
If StringInStr($pageArray[$i], $findtext) Then $Response =
_INetSmtpMail ($s_smtpserver, $s_FromName, $s_FromAdress,
$s_ToAdress, $s_Subject, $as_body, @computername, -1)

Error: "For" statement has no matching "Next" statement

Posted (edited)

The error message says it all: There is no "Next" statement.

Please have a look at the help file for "For/next" and you will see what I mean.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

The error message says it all: There is no "Next" statement.

Please have a look at the help file for "For/next" and you will see what I mean.

 

Thank you Mr Water for your reply,

   First i'm a beginner in AutoIt scripts, and if i understand, it's a condition, i must make a "next"  after the "for"  or i change the "then" by "next"

please help and really sorry for disturbing.

 

Best regards

Posted

Something like

For $i = 1 To $pageArray[0]
If StringInStr($pageArray[$i], $findtext) Then $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @computername, -1)
Next ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< here

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

ramoyous,

Post your script / reproducer or we are just guessing.

kylomas

 

Thank you for your replay,

#include <INet.au3>
$TextFileName = "C:\Users\X2Z\Desktop\Survey Monitor Close Control 1.30\Log.txt"
$s_SmtpServer = "server mail"
$s_FromName = ""
$s_Password = ""
$s_FromAddress = ""
$s_ToAddress = ""
$s_Subject = ""
Dim $as_Body[2]
$as_Body[0] = "Alert"
$as_Body[1] = "Defaut"
; First we read the text file
$Log = FileRead($TextFileName)
; Put the contents into an array
$pageArray = StringSplit($Log, @CRLF)
; Now go through the array and look for the word failure if its found send and email
For $i = 1 To $pageArray[0]
If StringInStr($pageArray[$i], $findtext) Then $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @computername, -1) Next
Posted

look up ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

look up ;)

 

:bye:   Thank you cool brain, i've seen it, but really I'm in a labyrinth, i've seen also the help about "For...in...Next"  but i think the "next" must be followed by something, that i don't know to put.

 

And sorry again to disturbing you

Posted

"Next" needs to be in the next line. So your code should like like:

#include <INet.au3>
$TextFileName = "C:\Users\X2Z\Desktop\Survey Monitor Close Control 1.30\Log.txt"
$s_SmtpServer = "server mail"
$s_FromName = ""
$s_Password = ""
$s_FromAddress = ""
$s_ToAddress = ""
$s_Subject = ""
Dim $as_Body[2]
$as_Body[0] = "Alert"
$as_Body[1] = "Defaut"
; First we read the text file
$Log = FileRead($TextFileName)
; Put the contents into an array
$pageArray = StringSplit($Log, @CRLF)
; Now go through the array and look for the word failure if its found send and email
For $i = 1 To $pageArray[0]
    If StringInStr($pageArray[$i], $findtext) Then $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @computername, -1) 
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

:bye:   Thank you cool brain, i've seen it, but really I'm in a labyrinth, i've seen also the help about "For...in...Next"  but i think the "next" must be followed by something, that i don't know to put.

 

And sorry again to disturbing you

 

You are more then fine, I am here to help :)

 

"Next" needs to be in the next line. So your code should like like:

#include <INet.au3>
$TextFileName = "C:\Users\X2Z\Desktop\Survey Monitor Close Control 1.30\Log.txt"
$s_SmtpServer = "server mail"
$s_FromName = ""
$s_Password = ""
$s_FromAddress = ""
$s_ToAddress = ""
$s_Subject = ""
Dim $as_Body[2]
$as_Body[0] = "Alert"
$as_Body[1] = "Defaut"
; First we read the text file
$Log = FileRead($TextFileName)
; Put the contents into an array
$pageArray = StringSplit($Log, @CRLF)
; Now go through the array and look for the word failure if its found send and email
For $i = 1 To $pageArray[0]
    If StringInStr($pageArray[$i], $findtext) Then $Response = _INetSmtpMail ($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @computername, -1) 
Next

 

As you can see Water has shown you this is a true solution to your problem, that is if it is your only problem ;)

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

Thank you all

    Mr Water, after adding the "next" variable  the error message has been changed to :

ERROR : Variable used without being declared

And really i don't know what can i put after it, sorry for my poor knowledge

And i want to inform you all that i have one 1 poste left on my account until the 08/10/2014.

 

So thank you all for your help and i'm waiting to solve my problem

 

Best regards

Posted

Then you need to replace the missing variable with the text you are looking for. I take it from your script that you are looking for "failure":

#include <INet.au3>
$TextFileName = "C:\Users\X2Z\Desktop\Survey Monitor Close Control 1.30\Log.txt"
$s_SmtpServer = "server mail"
$s_FromName = ""
$s_Password = ""
$s_FromAddress = ""
$s_ToAddress = ""
$s_Subject = ""
Dim $as_Body[2]
$as_Body[0] = "Alert"
$as_Body[1] = "Defaut"
; First we read the text file
$Log = FileRead($TextFileName)
; Put the contents into an array
$pageArray = StringSplit($Log, @CRLF)
; Now go through the array and look for the word failure if its found send and email
For $i = 1 To $pageArray[0]
    If StringInStr($pageArray[$i], "failure") Then $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, -1)
Next

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

 

Then you need to replace the missing variable with the text you are looking for. I take it from your script that you are looking for "failure":

#include <INet.au3>
$TextFileName = "C:\Users\X2Z\Desktop\Survey Monitor Close Control 1.30\Log.txt"
$s_SmtpServer = "server mail"
$s_FromName = ""
$s_Password = ""
$s_FromAddress = ""
$s_ToAddress = ""
$s_Subject = ""
Dim $as_Body[2]
$as_Body[0] = "Alert"
$as_Body[1] = "Defaut"
; First we read the text file
$Log = FileRead($TextFileName)
; Put the contents into an array
$pageArray = StringSplit($Log, @CRLF)
; Now go through the array and look for the word failure if its found send and email
For $i = 1 To $pageArray[0]
    If StringInStr($pageArray[$i], "failure") Then $Response = _INetSmtpMail($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ComputerName, -1)
Next

 

 

Thanks Mr Water again,

 

     after the change you made, and when i run the script, there is no more error message but it's not working, now i have no post to use to answear you. if it's not a problem i'm asking you to send me your mail, if not , i will be here tomorrow, to poste my results

 

Finally I thank you all for your help, your wisdom, your time and for sharing your knowledge

 

Best regards

Posted

It would be helpful if you could post an example of your text file (including a line with the text you search for).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

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