LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-11-2020, 10:41 AM   #16
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled

Here it is with proper indentation:

Code:
import smtplib

smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
smtpObj.ehlo()

smtpObj.starttls()

smtpObj.login('xx', 'xx')

with open('/var/log/suricata/fast.log', 'r') as file:
        lines=file.readlines()

g = open('/var/log/suricata/daylogs.txt', 'w+')

#print(g)

for i in range(1, 15):
        g.write(lines[i*-1])

print(g)

with open ('/var/log/suricata/daylogs.txt', 'r') as file:
        m = file.read()

#message = str(m)

#str.split(message)

print(m)

smtpObj.sendmail('xx@gmail.com', 'xx@gmail.com', 'Subject: IDS ALERTS\n\n'+m)

smtpObj.quit()
 
Old 05-11-2020, 10:48 AM   #17
jorjor242
Member
 
Registered: Apr 2020
Posts: 30

Original Poster
Rep: Reputation: Disabled
yes, g.close() before opening daylogs.txt fixed it. thanks!
 
  


Reply

Tags
cron, cronjob, python, python3, suricata



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python Script Runs Perfectly on Bash but Fails at Cronjob browny redandy Linux - Newbie 4 07-29-2015 05:18 AM
Do not run as cronjob, but manually executed works postcd Linux - General 1 01-09-2015 08:38 PM
[SOLVED] Writing to file with python script scheduled to run with cronjob rahatb Programming 2 04-03-2014 05:13 AM
LXer: Piracy creates jobs, FOSS creates opportunities LXer Syndicated Linux News 0 11-02-2006 11:33 AM
cronjob not working but script works dtra Linux - Newbie 4 02-28-2005 05:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration