Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
There is less than 24 hours left to vote in the 2015 LinuxQuestions.org Members Choice Awards. Click here to go to the polls. Vote now and make sure your voice is heard!
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
tredegar: thanks; i'd rather process "file1" with php directly (which is what I'm currently doing), but I really don't want the file growing unnecessarily big. I know I can rename/delete it on a periodic basis with a cronjob, but I'm looking for an "elegant" solution.
writes GOODBYE lines to file, but only after killing the telnet process (which is not useful)
Ah Ha! This is because your telnet to port 10001 is continually reading lines, and never finishes.
There must be a better way to get the data you need.
Maybe have the remote host write the sensor data to a file and then just scp the file from the remote host?
What sort of process do you have running on port 10001 on the remote host?
Can you make it send the sensor data, and then terminate the connection?
I don't mean to be rude, but I already said in the first post that the telnet produces an infinite loop and it's the only way to acquire data. source machine is given as a black box; no chance for scp. thanks.
Looks like a good idea, but I have almost no experience with bash. I don't know if the condition
"you_are_bored" might be a timestamp or a period of time, or a certain amount of lines in the
file, etc. So, it's gonna take a while for me to test, but I'll try it; thank you.
by the way, the exact phrase "the only way to acquire data is by using: $ telnet ..." is on my
first post indeed.
Looks like a good idea, but I have almost no experience with bash
I'm also still a beginner with bash, but not quite a "newbie".
The point I am making is that you are receiving an (it seems now, an endless) data-stream from your telnet command.
You can pipe (the "|" in my previous post) this data to a script that will read each line one at a time and assign each line to the variable $foo
You can then use bash scripting to deal with each line (as assigned to the variable $foo) in turn: If it is saying HELLO foo, then you can safely discard it (but why does it need to do this THIRTY times?)
If it is saying "GOODBYE "the data i care about (numbers)"" then you can filter this out ( maybe with grep and cut ?) and then process it as you see fit.
"you_are_bored" might be a timestamp or a period of time, or a certain amount of lines in the file, etc.
Well, that was a kind of a joke. Sorry. You could define you_are_bored=false and it would continue forever, which is maybe what you need. It was pseudocode anyway. Cheer up!
Seriously, I am alerting one of LQ's bash-gurus to this thread (Tinkster, are you listening? HELP!), and I hope he'll be able to help you better than I can. He may be busy though.
by the way, the exact phrase "the only way to acquire data is by using: $ telnet ..." is on my first post indeed.
Ok. I'm just trying to help you out. I'm busy too. My apologies if I mis-read.
I might not know a lot of bash scripting, but I do understand pseudocode; so when I said your idea looks good and I'm gonna try it, I really meant that (well, maybe next week, 'cause my work shift ends tomorrow); no need to further explain! Also, I did get the joke and appreciate your humor and help, 'cause in most forums people are jerks and treat you badly just for not knowing stuff. Actually, this is the only place where I have found nice, patient answers; so, thank you very much.
Just to satisfy your curiosity: the output strings aren't actually "HELLO foo" and "GOODBYE foo"; they're just 2 different strings followed by numbers. I changed them to explain easily. The HELLO lines contain current data for one sensor (every second) while the GOODBYE lines contain average values for all sensors every 30 secs, which are the data I need to work with. And the source data machine is a weather station with an IP, not a computer, hence the unfeasibility of any command other than telnet through port 10001.
***sorry if I broke any rules by going off topic ***
Tinkster is indeed busy, but he recommends you take a look at the telnet man-page, searching for "flush", and also suggests you may need to use expect to get it working.
netcat looks a good tool too (thanks michaelk)
So, give it a go.
If / when you come back here with some code that is partly working, it would be useful if you gave us a real sample of the data stream you are trying to process (within [CODE] tags please, so we can see exactly how it is formatted)