LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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.

Notices

Reply
 
Search this Thread
Old 03-16-2012, 11:28 AM   #1
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 545

Rep: Reputation: 30
Streaming output from a running program to a server on local network


I have an embedded Linux system with a very tiny amount of disk space. This system needs to run a program that continuously streams text to standard output, and I need to capture and log this information in case its needed for debugging purposes later. The embedded system is on a local network with a Linux server, and its on this server that I want to store the output log of the program running on the embedded system. So, what I am seeking is a way to stream output from the program across the network to the server, and the server will feed this data into a log file.


I thought that I could use nc/netcat to achieve this goal, but I'm having difficulty and haven't been able to find any good examples for how I could get this to work. Additionally, this log streaming is all going in a script file (one script on the server, and another on the embedded system) which needs to do many other things. So here's what I've got so far:

Server-side:
Code:
    nc -l $NC_PORT > /tmp/deltatau.out &
    ssh $LOGIN_DELTATAU@$IP_DELTATAU "/root/system_deltatau start"
Embedded-side:
Code:
    /root/test_deltatau | nc $IP_IMCS $NC_PORT &

The server side script calls NC to listen on a port I specify, instructs it to place its output in a file in /tmp, and launches the process to run in the background. Then it uses ssh to execute the script on the embedded side. The embedded side script launches the program and attempts to send its output across the network via nc.

But right now the server-side output file doesn't get populated (its empty) and the ssh command does not return until the test_deltatau program is completely finished (it should return immediately after launching said program). So I think that nc isn't being fed this output data at all right now.


I may be using nc all wrong, or maybe there's a better tool for this job than nc. I'm still playing around and trying a few different ideas that I have, but I was hoping that someone had experience solving this problem and was willing to share their advice. I'm trying to use as simple of a solution as possible, hopefully not requiring any custom software that is not already on a standard Linux system (recall, my embedded Linux system is very short on disc space). Thanks.
 
Old 03-16-2012, 01:59 PM   #2
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 545

Original Poster
Rep: Reputation: 30
Well upon further investigation these commands do work correctly if I do them on the command line instead of calling them within my script. So I'm wondering if somehow using ssh is screwing things up. I'm scratching my head at this now.
 
Old 03-18-2012, 08:00 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,251

Rep: Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026
I think you need
Code:
nohup <cmds> &
so that it detaches completely from the session.
Also the ssh cmd is calling /root/test_deltatau and so is the embedded side; isn't that recursive/redundant ?
 
1 members found this post helpful.
Old 03-19-2012, 09:06 AM   #4
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 545

Original Poster
Rep: Reputation: 30
Thanks, I'll give that a try and let you know if I get it to work or not.


The ssh command is actually calling /root/system_deltatau, which is a different script than test_deltatau. test_deltatau is just a temporary placeholder script to use for debugging until I get this working, then I'll call the actual program I want to use.
 
Old 03-19-2012, 11:24 AM   #5
R00ts
Member
 
Registered: Mar 2004
Location: Austin TX, USA
Distribution: Ubuntu 11.10, Fedora 16
Posts: 545

Original Poster
Rep: Reputation: 30
I think I got it figured out now. I was having some difficulty when trying to use nohup, so I was taking a look at the options for nc and decided to experiment with the "-d" option, which says it ignores stdin. When I tried to use this option on the embedded system though it said this was not a valid option, so I looked at the help page and I got something completely different than the man pages I see on my server and on websites (maybe its running a much older version of nc, who knows). One of the options I saw was "-e", which states "program to exec after connect". So I tried using that and everything works as I want it to now:

Code:
nc $IP_IMCS $NC_PORT -e /root/test_deltatau &
 
  


Reply

Tags
nc, netcat, streaming


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Darwin streaming server Video streaming local only ahmed_as8 Linux - Networking 2 05-28-2009 02:52 PM
Strange output when running a C program over itself Dralnu Programming 5 05-13-2009 04:15 PM
Streaming sound from remote X(XDMCP) server to local client avaneja Linux - Networking 1 10-20-2006 06:07 AM
SMB server running in the local network Gerardoj Linux - Networking 2 07-04-2003 12:41 PM
running program in local directory bob10a Linux - General 6 11-04-2002 06:48 PM


All times are GMT -5. The time now is 02:02 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration