Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > tail -5 (last 5 entry of the log file) 0 19:44:20.644 indicator1
- > EURUSD,Daily: initialized 0 19:44:20.644 indicator2 EURUSD,Daily:
- > initialized 0 19:44:20.645 indicator3 EURUSD,Daily: initialized
- > 0 19:44:20.646 indicator4 EURUSD,Daily: initialized
- > 0 19:44:20.659 indicator5 EURUSD,Daily: Alert: ! BUY ! - EURUSD
- > 0 19:44:20.659 indicator5 EURUSD,Daily: Alert: ! SELL ! - EURUSD
- #Powershell Script
- cls
- $dir = "C:Program Files (x86)Tickmill MT4 Client TerminalMQL4Logs"
- $filter="*.log"
- $latest = Get-ChildItem -Path $dir -Filter $filter | Sort-Object LastAccessTime -Descending | Select-Object -First 1
- Write-Host $latest
- #Select-String -Path "C:Program Files (x86)Tickmill MT4 Client TerminalMQL4Logs$latest" -Pattern 'BUY','SELL' | Select-Object -Last -Tail 1 -Wait
- #Get-Content -Path "C:Program Files (x86)Tickmill MT4 Client TerminalMQL4Logs$latest" -Tail 1 -Wait | where {if ($_ -match "sell" -or $_ -match "buy") {write-host "ALERT"}}
- function Send-ToEmail([string]$email){
- $user = "sender@email.com"
- $pass = ConvertTo-SecureString -String "PASSWORD" -AsPlainText -Force
- $cred = New-Object System.Management.Automation.PSCredential $user, $pass
- $body = ":("
- $mailParam = @{
- To = "sender@email.com"
- From = "ALERT ALERT <Reciever@email.com>"
- Subject = "ALERT : #tail last line"
- Body = $body
- SmtpServer = "smtp.gmail.com"
- Port = 587
- Credential = $cred
- #Attachments = "none"
- }
- # Send the email with all parameters
- Send-MailMessage @mailParam -UseSsl
- }
- while ($true) {
- Get-Content -Path "C:Program Files (x86)Tickmill MT4 Client TerminalMQL4Logs$latest" -Tail 1 -WAIT | where {if ($_ -match "sell" -or $_ -match "buy") {Send-ToEmail -email "receiver@email.com"}}
- start-sleep 2
- }
- `
Add Comment
Please, Sign In to add comment