Python Forum
Best way to feed python script of a file
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to feed python script of a file
#1
Hi!
I'm newbie in python.
I need to do a service/daemon in python that it's always executing and it should read of a file. These file contains lines of an application that are generated by an application (like a log).
Python script should manage the lines in order and do things.
What's the best way to achive that?
In unix I use bash and FIFO file but I don't know how it's the best way with python and windows.
Thanks!
Reply
#2
How about opening the file and reading it? Or may be I misunderstand the question?
absolut likes this post
« We can solve any problem by introducing an extra level of indirection »
Reply
#3
Yes, you have reason.
But I need to manage every line once. I mean when I manage one line, these line I don't have to manage another time, so I need to discard it. Sorry for my english.
Reply
#4
(Jan-10-2025, 10:03 PM)absolut Wrote: when I manage one line, these line I don't have to manage another time, so I need to discard it.
It is very difficult to understand (and it is not due to your english, besides you can use google translate to help you write in english).

Let's say you have the daemon D which processes the data and the application A that produces the data (say lines of text).

What does A do with its data? does it write it to a file that grows indefinitely?

You could perhaps show us how you do in Linux with bash and fifos. This would clarify the relation between A and D. Currently, I don't see what you are doing.
« We can solve any problem by introducing an extra level of indirection »
Reply
#5
(Jan-10-2025, 09:40 PM)Gribouillis Wrote: How about opening the file and reading it? Or may be I misunderstand the question?

(Jan-10-2025, 10:12 PM)Gribouillis Wrote:
(Jan-10-2025, 10:03 PM)absolut Wrote: when I manage one line, these line I don't have to manage another time, so I need to discard it.
It is very difficult to understand (and it is not due to your english, besides you can use google translate to help you write in english).

Let's say you have the daemon D which processes the data and the application A that produces the data (say lines of text).

What does A do with its data? does it write it to a file that grows indefinitely?

You could perhaps show us how you do in Linux with bash and fifos. This would clarify the relation between A and D. Currently, I don't see what you are doing.
Sorry I'm trying to explain better.
I have a program that generate snmp traps. The program could be configured to execute a shell script that get these snmp traps. With these script I feed a FIFO file, and then with a Daemon in Linux I read that file and I manage every line to filter the snmp data and then make a rest call to a api server if the filter matches.
I need to traslate that to windows system and I have thought to do in python language.
Reply
#6
(Jan-10-2025, 09:40 PM)Gribouillis Wrote: How about opening the file and reading it? Or may be I misunderstand the question?

(Jan-10-2025, 10:12 PM)Gribouillis Wrote:
(Jan-10-2025, 10:03 PM)absolut Wrote: when I manage one line, these line I don't have to manage another time, so I need to discard it.
It is very difficult to understand (and it is not due to your english, besides you can use google translate to help you write in english).

Let's say you have the daemon D which processes the data and the application A that produces the data (say lines of text).

What does A do with its data? does it write it to a file that grows indefinitely?

You could perhaps show us how you do in Linux with bash and fifos. This would clarify the relation between A and D. Currently, I don't see what you are doing.
Sorry I'm trying to explain better.
I have a program that generate snmp traps. The program could be configured to execute a shell script that get these snmp traps. With these script I feed a FIFO file, and then with a Daemon in Linux I read that file and I manage every line to filter the snmp data and then make a rest call to a api server if the filter matches.
I need to traslate that to windows system and I have thought to do in python language.
Reply
#7
(Jan-10-2025, 10:45 PM)absolut Wrote: The program could be configured to execute a shell script that get these snmp traps.
How will you configure the program in Windows? Will a script get the snmp traps?
(Jan-10-2025, 10:45 PM)absolut Wrote: With these script I feed a FIFO file
You could perhaps send the data to a socket instead of a FIFO file.

The daemon could start a server that listens on a socket and the script or program that gets the snmp traps could connect to this server and send messages.
« We can solve any problem by introducing an extra level of indirection »
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] [listbox] Feed it with dict passed to class? Winfried 3 1,026 May-13-2024, 05:57 AM
Last Post: Larz60+
Exclamation Multi-Threaded Camera Feed issue Khajababa69 0 1,119 May-05-2024, 09:44 PM
Last Post: Khajababa69
  Draw bounding boxes on live feed Jerome 0 969 Jan-20-2024, 10:50 PM
Last Post: Jerome
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 6,232 Jun-29-2023, 11:57 AM
Last Post: gologica
  Python Script to convert Json to CSV file chvsnarayana 8 4,070 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  How to modify python script to append data on file using sql server 2019? ahmedbarbary 1 1,827 Aug-03-2022, 06:03 AM
Last Post: Pedroski55
  How to parse a live feed in Python? Daring_T 2 6,978 Jan-20-2022, 04:17 AM
Last Post: Daring_T
  Feed List items with Integer euras 9 5,219 May-19-2021, 07:45 PM
Last Post: snippsat
  splitting UAV/sat images to smaller pieces in order to feed a CNN hobbyist 0 1,894 Dec-08-2020, 11:48 AM
Last Post: hobbyist
  Rotation Effect on live Webcam Feed Leziiy 0 2,002 Sep-12-2020, 04:25 PM
Last Post: Leziiy

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020