Guest User

Untitled

a guest
Dec 6th, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. > tail -5 (last 5 entry of the log file) 0 19:44:20.644 indicator1
  2. > EURUSD,Daily: initialized 0 19:44:20.644 indicator2 EURUSD,Daily:
  3. > initialized 0 19:44:20.645 indicator3 EURUSD,Daily: initialized
  4. > 0 19:44:20.646 indicator4 EURUSD,Daily: initialized
  5. > 0 19:44:20.659 indicator5 EURUSD,Daily: Alert: ! BUY ! - EURUSD
  6. > 0 19:44:20.659 indicator5 EURUSD,Daily: Alert: ! SELL ! - EURUSD
  7.  
  8. #Powershell Script
  9. cls
  10. $dir = "C:Program Files (x86)Tickmill MT4 Client TerminalMQL4Logs"
  11. $filter="*.log"
  12. $latest = Get-ChildItem -Path $dir -Filter $filter | Sort-Object LastAccessTime -Descending | Select-Object -First 1
  13. Write-Host $latest
  14.  
  15.  
  16.  
  17. #Select-String -Path "C:Program Files (x86)Tickmill MT4 Client TerminalMQL4Logs$latest" -Pattern 'BUY','SELL' | Select-Object -Last -Tail 1 -Wait
  18. #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"}}
  19.  
  20.  
  21. function Send-ToEmail([string]$email){
  22.  
  23. $user = "sender@email.com"
  24. $pass = ConvertTo-SecureString -String "PASSWORD" -AsPlainText -Force
  25. $cred = New-Object System.Management.Automation.PSCredential $user, $pass
  26. $body = ":("
  27. $mailParam = @{
  28. To = "sender@email.com"
  29. From = "ALERT ALERT <Reciever@email.com>"
  30. Subject = "ALERT : #tail last line"
  31. Body = $body
  32. SmtpServer = "smtp.gmail.com"
  33. Port = 587
  34. Credential = $cred
  35. #Attachments = "none"
  36. }
  37.  
  38. # Send the email with all parameters
  39. Send-MailMessage @mailParam -UseSsl
  40.  
  41. }
  42.  
  43.  
  44.  
  45. while ($true) {
  46.  
  47. 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"}}
  48.  
  49. start-sleep 2
  50.  
  51. }
  52.  
  53.  
  54. `
Add Comment
Please, Sign In to add comment