Problem in reading from socket
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
I have a spark streaming program, that reads data from a socket I have craeted using:
nc -lk 9999
The program reads the data from socket and exclude the "Error" messages. When I write manually in socket, it works fine.
I have created a python script that prints "Error" messages frequently. I will save the result in a file using:
stdbuf -oL python my_script.py &>> my_file.txt
and read the file from the socket:
nc -lk 9999 | tail -f my_file.txt
Every thing is ok, the socket will read data from file while the file is being updated on the background, But the problem is that my spark program doen't capture the "Error" messages.
As a summary:
when I write manually "Error" messages in socket, spark capture them,
But it won't capture "Error" message generated by python script from socket.
Actually the program doesn't work if I read file from socket instead of typing in it.
What is the difference?
command-line python files sockets
add a comment |Â
up vote
1
down vote
favorite
I have a spark streaming program, that reads data from a socket I have craeted using:
nc -lk 9999
The program reads the data from socket and exclude the "Error" messages. When I write manually in socket, it works fine.
I have created a python script that prints "Error" messages frequently. I will save the result in a file using:
stdbuf -oL python my_script.py &>> my_file.txt
and read the file from the socket:
nc -lk 9999 | tail -f my_file.txt
Every thing is ok, the socket will read data from file while the file is being updated on the background, But the problem is that my spark program doen't capture the "Error" messages.
As a summary:
when I write manually "Error" messages in socket, spark capture them,
But it won't capture "Error" message generated by python script from socket.
Actually the program doesn't work if I read file from socket instead of typing in it.
What is the difference?
command-line python files sockets
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a spark streaming program, that reads data from a socket I have craeted using:
nc -lk 9999
The program reads the data from socket and exclude the "Error" messages. When I write manually in socket, it works fine.
I have created a python script that prints "Error" messages frequently. I will save the result in a file using:
stdbuf -oL python my_script.py &>> my_file.txt
and read the file from the socket:
nc -lk 9999 | tail -f my_file.txt
Every thing is ok, the socket will read data from file while the file is being updated on the background, But the problem is that my spark program doen't capture the "Error" messages.
As a summary:
when I write manually "Error" messages in socket, spark capture them,
But it won't capture "Error" message generated by python script from socket.
Actually the program doesn't work if I read file from socket instead of typing in it.
What is the difference?
command-line python files sockets
I have a spark streaming program, that reads data from a socket I have craeted using:
nc -lk 9999
The program reads the data from socket and exclude the "Error" messages. When I write manually in socket, it works fine.
I have created a python script that prints "Error" messages frequently. I will save the result in a file using:
stdbuf -oL python my_script.py &>> my_file.txt
and read the file from the socket:
nc -lk 9999 | tail -f my_file.txt
Every thing is ok, the socket will read data from file while the file is being updated on the background, But the problem is that my spark program doen't capture the "Error" messages.
As a summary:
when I write manually "Error" messages in socket, spark capture them,
But it won't capture "Error" message generated by python script from socket.
Actually the program doesn't work if I read file from socket instead of typing in it.
What is the difference?
command-line python files sockets
edited May 20 at 14:48
asked May 20 at 14:41
![](https://i.stack.imgur.com/HnKD8.jpg?s=32&g=1)
![](https://i.stack.imgur.com/HnKD8.jpg?s=32&g=1)
Ali Majed HA
1356
1356
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The command you typed
nc -lk 9999 | tail -f my_file.txt
means: Take the output of netcat
and pipe that to tail -f my_file.txt
. But tail
doesn't accept any input, it merely watches the file my_file.txt
. Try
tail -f my_file.txt | nc -lk 9999
instead, so that the output of tail
is fed to nc
.
You are welcome. Just a note: perhaps it might be easier to use named pipes in your case or (given your previous question about rsyslog) makersyslog
directly write tomy_file.txt
instead of a socket. Just an idea. But perhaps I didn't fully understand your setup.
â PerlDuck
May 20 at 15:15
Nice idea my friend, your answer to my previous question has greatly worked. As I need to generate stream of messages in a short time, I have used this script to do that instead ofrsyslog
. Thank again
â Ali Majed HA
May 20 at 15:34
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The command you typed
nc -lk 9999 | tail -f my_file.txt
means: Take the output of netcat
and pipe that to tail -f my_file.txt
. But tail
doesn't accept any input, it merely watches the file my_file.txt
. Try
tail -f my_file.txt | nc -lk 9999
instead, so that the output of tail
is fed to nc
.
You are welcome. Just a note: perhaps it might be easier to use named pipes in your case or (given your previous question about rsyslog) makersyslog
directly write tomy_file.txt
instead of a socket. Just an idea. But perhaps I didn't fully understand your setup.
â PerlDuck
May 20 at 15:15
Nice idea my friend, your answer to my previous question has greatly worked. As I need to generate stream of messages in a short time, I have used this script to do that instead ofrsyslog
. Thank again
â Ali Majed HA
May 20 at 15:34
add a comment |Â
up vote
1
down vote
accepted
The command you typed
nc -lk 9999 | tail -f my_file.txt
means: Take the output of netcat
and pipe that to tail -f my_file.txt
. But tail
doesn't accept any input, it merely watches the file my_file.txt
. Try
tail -f my_file.txt | nc -lk 9999
instead, so that the output of tail
is fed to nc
.
You are welcome. Just a note: perhaps it might be easier to use named pipes in your case or (given your previous question about rsyslog) makersyslog
directly write tomy_file.txt
instead of a socket. Just an idea. But perhaps I didn't fully understand your setup.
â PerlDuck
May 20 at 15:15
Nice idea my friend, your answer to my previous question has greatly worked. As I need to generate stream of messages in a short time, I have used this script to do that instead ofrsyslog
. Thank again
â Ali Majed HA
May 20 at 15:34
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The command you typed
nc -lk 9999 | tail -f my_file.txt
means: Take the output of netcat
and pipe that to tail -f my_file.txt
. But tail
doesn't accept any input, it merely watches the file my_file.txt
. Try
tail -f my_file.txt | nc -lk 9999
instead, so that the output of tail
is fed to nc
.
The command you typed
nc -lk 9999 | tail -f my_file.txt
means: Take the output of netcat
and pipe that to tail -f my_file.txt
. But tail
doesn't accept any input, it merely watches the file my_file.txt
. Try
tail -f my_file.txt | nc -lk 9999
instead, so that the output of tail
is fed to nc
.
answered May 20 at 14:53
![](https://i.stack.imgur.com/kCmqs.png?s=32&g=1)
![](https://i.stack.imgur.com/kCmqs.png?s=32&g=1)
PerlDuck
3,62911030
3,62911030
You are welcome. Just a note: perhaps it might be easier to use named pipes in your case or (given your previous question about rsyslog) makersyslog
directly write tomy_file.txt
instead of a socket. Just an idea. But perhaps I didn't fully understand your setup.
â PerlDuck
May 20 at 15:15
Nice idea my friend, your answer to my previous question has greatly worked. As I need to generate stream of messages in a short time, I have used this script to do that instead ofrsyslog
. Thank again
â Ali Majed HA
May 20 at 15:34
add a comment |Â
You are welcome. Just a note: perhaps it might be easier to use named pipes in your case or (given your previous question about rsyslog) makersyslog
directly write tomy_file.txt
instead of a socket. Just an idea. But perhaps I didn't fully understand your setup.
â PerlDuck
May 20 at 15:15
Nice idea my friend, your answer to my previous question has greatly worked. As I need to generate stream of messages in a short time, I have used this script to do that instead ofrsyslog
. Thank again
â Ali Majed HA
May 20 at 15:34
You are welcome. Just a note: perhaps it might be easier to use named pipes in your case or (given your previous question about rsyslog) make
rsyslog
directly write to my_file.txt
instead of a socket. Just an idea. But perhaps I didn't fully understand your setup.â PerlDuck
May 20 at 15:15
You are welcome. Just a note: perhaps it might be easier to use named pipes in your case or (given your previous question about rsyslog) make
rsyslog
directly write to my_file.txt
instead of a socket. Just an idea. But perhaps I didn't fully understand your setup.â PerlDuck
May 20 at 15:15
Nice idea my friend, your answer to my previous question has greatly worked. As I need to generate stream of messages in a short time, I have used this script to do that instead of
rsyslog
. Thank againâ Ali Majed HA
May 20 at 15:34
Nice idea my friend, your answer to my previous question has greatly worked. As I need to generate stream of messages in a short time, I have used this script to do that instead of
rsyslog
. Thank againâ Ali Majed HA
May 20 at 15:34
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1038403%2fproblem-in-reading-from-socket%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password