Problem in reading from socket

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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?







share|improve this question


























    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?







    share|improve this question
























      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?







      share|improve this question














      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?









      share|improve this question













      share|improve this question




      share|improve this question








      edited May 20 at 14:48

























      asked May 20 at 14:41









      Ali Majed HA

      1356




      1356




















          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.






          share|improve this answer




















          • 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










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          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






























          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.






          share|improve this answer




















          • 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














          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.






          share|improve this answer




















          • 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












          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 20 at 14:53









          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) 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
















          • 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















          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












           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          pylint3 and pip3 broken

          Missing snmpget and snmpwalk

          How to enroll fingerprints to Ubuntu 17.10 with VFS491