USB data logging Ubuntu MATE

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











up vote
1
down vote

favorite












Using Ubuntu Mate, raspberry pi. I am new to programming and very new to bash. Simply put: USB data to CSV, I can try anything even without script.



Edit: The device will be in loop, so stopping it to receive data is a no-no. Real time data filtering to only receive the real data.



To my other question which is similar: Linux terminal output to file, but as filtered?



I have python script given by the company who made the RF receiver (Script at end). This is most likely an user error.



This is what I wrote at the terminal:



python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | filter.pl >> output.csv
[1+] Stopped
Filter.pl: command not found


With sed terminal:



python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | sed -n "s/^b';[0-9]3];(.+);'/1/p" >> output_file


Result: Flashing input thingy and after CTRL + C



Exception ignored in: <_io.TextIOrapper name='<stdout>' mode='w' ecpmdomg='UTF-8'> 
BrokenPipeError:[Errno32] Broken pipe.


NOTE: I need only longer part, from there I will parse it even more to send it to AT&T M2X online service.



b';"Anything from 1-9999";'
b';311;'

b';312;'

b';312;00000000;036;552;1014f49;3020;2659;6294;1049;2659;S;'

b';313;'


Script.py:



#! / Usr / bin / python
# Coding: UTF-8

################################################## #########################
# (C) Tokyo Cosmos Electric, Inc. (TOCOS) - all rights reserved.
# Terms and Conditions:
# - This source code, as long as the Tokyo Cosmos Electric Co., Ltd. copyright separately there is no source code license description
# We will not hold.
# - This source code is no warranty-free support. Any damage which the present source code and product
Tokyo Cosmos Electric Co., Ltd. does not guarantee also #. Report of trouble etc. will be welcome.
# - This source code is published on the premise that run with TWE series Tokyo Cosmos Electric Co., Ltd. to sell
# doing.
################################################## #########################

### Script to read the TWE-Lite standard application
# ? this script is read-only, to do the reading and writing both will require processing by multiple threads.

from serial import *
from sys import stdout, stdin, stderr, exit

Confirmation of # parameter
# First argument: serial port name
! if len (sys.argv) = 2:
print "% s serial port name"% sys.argv [0]
exit (1)

# Open a serial port
try:
ser = Serial (sys.argv [1], 115200)
print "open serial port:% s"% sys.argv [1]
except:
print "can not open serial port:% s"% sys.argv [1]
exit (1)

# Display of other messages (output the payload)
def printPayload (l):
if len (l) <3: return False # check of data size

print "command = 0x% 02x (other)"% l [1]
print "src = 0x% 02x"% l [0]

# Directly outputs the payload
print "payload =",
for c in l [2:]:
print "% 02x"% c,
print "(hex)"
return True

# 0x81 interpretation of the message
def printPayload_0x81 (l):
if len (l) = 23:! return False # check of data size

ladr = l [5] << 24 | l [6] << 16 | l [7] << 8 | l [8]
print "command = 0x% 02x (data arrival)"% l [1]
print "src = 0x% 02x"% l [0]
print "src long = 0x% 08x"% ladr
print "dst = 0x% 02x"% l [9]
print "pktid = 0x% 02x"% l [2]
print "prtcl ver = 0x% 02x"% l [3]
print "LQI =% d /% .2f [dbm]"% (l [4], (7 * l [4] -1970) / 20.)
ts = l [10] << 8 | l [11]
print "time stmp =% .3f [s]"% (ts / 64.0)
print "relay flg =% d"% l [12]
vlt = l [13] << 8 | l [14]
print "volt =% 04d [mV]"% vlt

Data of # DI1..4
dibm = l [16]
dibm_chg = l [17]
di = # of the current state
di_chg = # 1 Once in Lo (1) at least once
for i in range (1,5):
di [i] = 0 if (dibm & 0x1) == 0 else 1
di_chg [i] = 0 if (dibm_chg & 0x1) == 0 else 1
dibm >> = 1
dibm_chg >> = 1
pass

print "DI1 =% d /% d DI2 =% d /% d DI3 =% d /% d DI4 =% d /% d"% (di [1], di_chg [1], di [2], di_chg [ 2], di [3], di_chg [3], di [4], di_chg [4])

Data of # AD1..4
ad =
er = l [22]
for i in range (1,5):
av = l [i + 18 - 1]
if av == 0xFF:
# AD and if the port is unused treatment (approximately 2V or more) -1
ad [i] = -1
else:
# Calculation, including the correction bits
ad [i] = ((av * 4) + (er & 0x3)) * 4
er >> = 2
print "AD1 =% 04d AD2 =% 04d AD3 =% 04d AD4 =% 04d [mV]"% (ad [1], ad [2], ad [3], ad [4])

return True

# Interpret the data line by line
while True:
line = ser.readline (). rstrip () # to read in one line units, and remove the trailing line feed code (blocking read)

if len (line)> 0 and line [0] == ':':
print " n% s"% line
else:
continue

try:
lst = map (ord, line [1:]. decode ('hex')) # convert the HEX string after decoding the string, to each ord and () the list
csum = sum (lst) & 0xff # checksum if 0 by adding a total of 8bit calculation OK
lst.pop () remove the # checksum from the list
if csum == 0:
if lst [1] == 0x81:
printPayload_0x81 (lst) # reception of IO-related data
else:
printPayload (lst) # Other data reception
else:
print "checksum ng"
except:
print "skip" # when an error









share|improve this question



























    up vote
    1
    down vote

    favorite












    Using Ubuntu Mate, raspberry pi. I am new to programming and very new to bash. Simply put: USB data to CSV, I can try anything even without script.



    Edit: The device will be in loop, so stopping it to receive data is a no-no. Real time data filtering to only receive the real data.



    To my other question which is similar: Linux terminal output to file, but as filtered?



    I have python script given by the company who made the RF receiver (Script at end). This is most likely an user error.



    This is what I wrote at the terminal:



    python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | filter.pl >> output.csv
    [1+] Stopped
    Filter.pl: command not found


    With sed terminal:



    python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | sed -n "s/^b';[0-9]3];(.+);'/1/p" >> output_file


    Result: Flashing input thingy and after CTRL + C



    Exception ignored in: <_io.TextIOrapper name='<stdout>' mode='w' ecpmdomg='UTF-8'> 
    BrokenPipeError:[Errno32] Broken pipe.


    NOTE: I need only longer part, from there I will parse it even more to send it to AT&T M2X online service.



    b';"Anything from 1-9999";'
    b';311;'

    b';312;'

    b';312;00000000;036;552;1014f49;3020;2659;6294;1049;2659;S;'

    b';313;'


    Script.py:



    #! / Usr / bin / python
    # Coding: UTF-8

    ################################################## #########################
    # (C) Tokyo Cosmos Electric, Inc. (TOCOS) - all rights reserved.
    # Terms and Conditions:
    # - This source code, as long as the Tokyo Cosmos Electric Co., Ltd. copyright separately there is no source code license description
    # We will not hold.
    # - This source code is no warranty-free support. Any damage which the present source code and product
    Tokyo Cosmos Electric Co., Ltd. does not guarantee also #. Report of trouble etc. will be welcome.
    # - This source code is published on the premise that run with TWE series Tokyo Cosmos Electric Co., Ltd. to sell
    # doing.
    ################################################## #########################

    ### Script to read the TWE-Lite standard application
    # ? this script is read-only, to do the reading and writing both will require processing by multiple threads.

    from serial import *
    from sys import stdout, stdin, stderr, exit

    Confirmation of # parameter
    # First argument: serial port name
    ! if len (sys.argv) = 2:
    print "% s serial port name"% sys.argv [0]
    exit (1)

    # Open a serial port
    try:
    ser = Serial (sys.argv [1], 115200)
    print "open serial port:% s"% sys.argv [1]
    except:
    print "can not open serial port:% s"% sys.argv [1]
    exit (1)

    # Display of other messages (output the payload)
    def printPayload (l):
    if len (l) <3: return False # check of data size

    print "command = 0x% 02x (other)"% l [1]
    print "src = 0x% 02x"% l [0]

    # Directly outputs the payload
    print "payload =",
    for c in l [2:]:
    print "% 02x"% c,
    print "(hex)"
    return True

    # 0x81 interpretation of the message
    def printPayload_0x81 (l):
    if len (l) = 23:! return False # check of data size

    ladr = l [5] << 24 | l [6] << 16 | l [7] << 8 | l [8]
    print "command = 0x% 02x (data arrival)"% l [1]
    print "src = 0x% 02x"% l [0]
    print "src long = 0x% 08x"% ladr
    print "dst = 0x% 02x"% l [9]
    print "pktid = 0x% 02x"% l [2]
    print "prtcl ver = 0x% 02x"% l [3]
    print "LQI =% d /% .2f [dbm]"% (l [4], (7 * l [4] -1970) / 20.)
    ts = l [10] << 8 | l [11]
    print "time stmp =% .3f [s]"% (ts / 64.0)
    print "relay flg =% d"% l [12]
    vlt = l [13] << 8 | l [14]
    print "volt =% 04d [mV]"% vlt

    Data of # DI1..4
    dibm = l [16]
    dibm_chg = l [17]
    di = # of the current state
    di_chg = # 1 Once in Lo (1) at least once
    for i in range (1,5):
    di [i] = 0 if (dibm & 0x1) == 0 else 1
    di_chg [i] = 0 if (dibm_chg & 0x1) == 0 else 1
    dibm >> = 1
    dibm_chg >> = 1
    pass

    print "DI1 =% d /% d DI2 =% d /% d DI3 =% d /% d DI4 =% d /% d"% (di [1], di_chg [1], di [2], di_chg [ 2], di [3], di_chg [3], di [4], di_chg [4])

    Data of # AD1..4
    ad =
    er = l [22]
    for i in range (1,5):
    av = l [i + 18 - 1]
    if av == 0xFF:
    # AD and if the port is unused treatment (approximately 2V or more) -1
    ad [i] = -1
    else:
    # Calculation, including the correction bits
    ad [i] = ((av * 4) + (er & 0x3)) * 4
    er >> = 2
    print "AD1 =% 04d AD2 =% 04d AD3 =% 04d AD4 =% 04d [mV]"% (ad [1], ad [2], ad [3], ad [4])

    return True

    # Interpret the data line by line
    while True:
    line = ser.readline (). rstrip () # to read in one line units, and remove the trailing line feed code (blocking read)

    if len (line)> 0 and line [0] == ':':
    print " n% s"% line
    else:
    continue

    try:
    lst = map (ord, line [1:]. decode ('hex')) # convert the HEX string after decoding the string, to each ord and () the list
    csum = sum (lst) & 0xff # checksum if 0 by adding a total of 8bit calculation OK
    lst.pop () remove the # checksum from the list
    if csum == 0:
    if lst [1] == 0x81:
    printPayload_0x81 (lst) # reception of IO-related data
    else:
    printPayload (lst) # Other data reception
    else:
    print "checksum ng"
    except:
    print "skip" # when an error









    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Using Ubuntu Mate, raspberry pi. I am new to programming and very new to bash. Simply put: USB data to CSV, I can try anything even without script.



      Edit: The device will be in loop, so stopping it to receive data is a no-no. Real time data filtering to only receive the real data.



      To my other question which is similar: Linux terminal output to file, but as filtered?



      I have python script given by the company who made the RF receiver (Script at end). This is most likely an user error.



      This is what I wrote at the terminal:



      python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | filter.pl >> output.csv
      [1+] Stopped
      Filter.pl: command not found


      With sed terminal:



      python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | sed -n "s/^b';[0-9]3];(.+);'/1/p" >> output_file


      Result: Flashing input thingy and after CTRL + C



      Exception ignored in: <_io.TextIOrapper name='<stdout>' mode='w' ecpmdomg='UTF-8'> 
      BrokenPipeError:[Errno32] Broken pipe.


      NOTE: I need only longer part, from there I will parse it even more to send it to AT&T M2X online service.



      b';"Anything from 1-9999";'
      b';311;'

      b';312;'

      b';312;00000000;036;552;1014f49;3020;2659;6294;1049;2659;S;'

      b';313;'


      Script.py:



      #! / Usr / bin / python
      # Coding: UTF-8

      ################################################## #########################
      # (C) Tokyo Cosmos Electric, Inc. (TOCOS) - all rights reserved.
      # Terms and Conditions:
      # - This source code, as long as the Tokyo Cosmos Electric Co., Ltd. copyright separately there is no source code license description
      # We will not hold.
      # - This source code is no warranty-free support. Any damage which the present source code and product
      Tokyo Cosmos Electric Co., Ltd. does not guarantee also #. Report of trouble etc. will be welcome.
      # - This source code is published on the premise that run with TWE series Tokyo Cosmos Electric Co., Ltd. to sell
      # doing.
      ################################################## #########################

      ### Script to read the TWE-Lite standard application
      # ? this script is read-only, to do the reading and writing both will require processing by multiple threads.

      from serial import *
      from sys import stdout, stdin, stderr, exit

      Confirmation of # parameter
      # First argument: serial port name
      ! if len (sys.argv) = 2:
      print "% s serial port name"% sys.argv [0]
      exit (1)

      # Open a serial port
      try:
      ser = Serial (sys.argv [1], 115200)
      print "open serial port:% s"% sys.argv [1]
      except:
      print "can not open serial port:% s"% sys.argv [1]
      exit (1)

      # Display of other messages (output the payload)
      def printPayload (l):
      if len (l) <3: return False # check of data size

      print "command = 0x% 02x (other)"% l [1]
      print "src = 0x% 02x"% l [0]

      # Directly outputs the payload
      print "payload =",
      for c in l [2:]:
      print "% 02x"% c,
      print "(hex)"
      return True

      # 0x81 interpretation of the message
      def printPayload_0x81 (l):
      if len (l) = 23:! return False # check of data size

      ladr = l [5] << 24 | l [6] << 16 | l [7] << 8 | l [8]
      print "command = 0x% 02x (data arrival)"% l [1]
      print "src = 0x% 02x"% l [0]
      print "src long = 0x% 08x"% ladr
      print "dst = 0x% 02x"% l [9]
      print "pktid = 0x% 02x"% l [2]
      print "prtcl ver = 0x% 02x"% l [3]
      print "LQI =% d /% .2f [dbm]"% (l [4], (7 * l [4] -1970) / 20.)
      ts = l [10] << 8 | l [11]
      print "time stmp =% .3f [s]"% (ts / 64.0)
      print "relay flg =% d"% l [12]
      vlt = l [13] << 8 | l [14]
      print "volt =% 04d [mV]"% vlt

      Data of # DI1..4
      dibm = l [16]
      dibm_chg = l [17]
      di = # of the current state
      di_chg = # 1 Once in Lo (1) at least once
      for i in range (1,5):
      di [i] = 0 if (dibm & 0x1) == 0 else 1
      di_chg [i] = 0 if (dibm_chg & 0x1) == 0 else 1
      dibm >> = 1
      dibm_chg >> = 1
      pass

      print "DI1 =% d /% d DI2 =% d /% d DI3 =% d /% d DI4 =% d /% d"% (di [1], di_chg [1], di [2], di_chg [ 2], di [3], di_chg [3], di [4], di_chg [4])

      Data of # AD1..4
      ad =
      er = l [22]
      for i in range (1,5):
      av = l [i + 18 - 1]
      if av == 0xFF:
      # AD and if the port is unused treatment (approximately 2V or more) -1
      ad [i] = -1
      else:
      # Calculation, including the correction bits
      ad [i] = ((av * 4) + (er & 0x3)) * 4
      er >> = 2
      print "AD1 =% 04d AD2 =% 04d AD3 =% 04d AD4 =% 04d [mV]"% (ad [1], ad [2], ad [3], ad [4])

      return True

      # Interpret the data line by line
      while True:
      line = ser.readline (). rstrip () # to read in one line units, and remove the trailing line feed code (blocking read)

      if len (line)> 0 and line [0] == ':':
      print " n% s"% line
      else:
      continue

      try:
      lst = map (ord, line [1:]. decode ('hex')) # convert the HEX string after decoding the string, to each ord and () the list
      csum = sum (lst) & 0xff # checksum if 0 by adding a total of 8bit calculation OK
      lst.pop () remove the # checksum from the list
      if csum == 0:
      if lst [1] == 0x81:
      printPayload_0x81 (lst) # reception of IO-related data
      else:
      printPayload (lst) # Other data reception
      else:
      print "checksum ng"
      except:
      print "skip" # when an error









      share|improve this question















      Using Ubuntu Mate, raspberry pi. I am new to programming and very new to bash. Simply put: USB data to CSV, I can try anything even without script.



      Edit: The device will be in loop, so stopping it to receive data is a no-no. Real time data filtering to only receive the real data.



      To my other question which is similar: Linux terminal output to file, but as filtered?



      I have python script given by the company who made the RF receiver (Script at end). This is most likely an user error.



      This is what I wrote at the terminal:



      python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | filter.pl >> output.csv
      [1+] Stopped
      Filter.pl: command not found


      With sed terminal:



      python3 'home/#USER/Desktop/python/script.py' /dev/ttyUSB0 | sed -n "s/^b';[0-9]3];(.+);'/1/p" >> output_file


      Result: Flashing input thingy and after CTRL + C



      Exception ignored in: <_io.TextIOrapper name='<stdout>' mode='w' ecpmdomg='UTF-8'> 
      BrokenPipeError:[Errno32] Broken pipe.


      NOTE: I need only longer part, from there I will parse it even more to send it to AT&T M2X online service.



      b';"Anything from 1-9999";'
      b';311;'

      b';312;'

      b';312;00000000;036;552;1014f49;3020;2659;6294;1049;2659;S;'

      b';313;'


      Script.py:



      #! / Usr / bin / python
      # Coding: UTF-8

      ################################################## #########################
      # (C) Tokyo Cosmos Electric, Inc. (TOCOS) - all rights reserved.
      # Terms and Conditions:
      # - This source code, as long as the Tokyo Cosmos Electric Co., Ltd. copyright separately there is no source code license description
      # We will not hold.
      # - This source code is no warranty-free support. Any damage which the present source code and product
      Tokyo Cosmos Electric Co., Ltd. does not guarantee also #. Report of trouble etc. will be welcome.
      # - This source code is published on the premise that run with TWE series Tokyo Cosmos Electric Co., Ltd. to sell
      # doing.
      ################################################## #########################

      ### Script to read the TWE-Lite standard application
      # ? this script is read-only, to do the reading and writing both will require processing by multiple threads.

      from serial import *
      from sys import stdout, stdin, stderr, exit

      Confirmation of # parameter
      # First argument: serial port name
      ! if len (sys.argv) = 2:
      print "% s serial port name"% sys.argv [0]
      exit (1)

      # Open a serial port
      try:
      ser = Serial (sys.argv [1], 115200)
      print "open serial port:% s"% sys.argv [1]
      except:
      print "can not open serial port:% s"% sys.argv [1]
      exit (1)

      # Display of other messages (output the payload)
      def printPayload (l):
      if len (l) <3: return False # check of data size

      print "command = 0x% 02x (other)"% l [1]
      print "src = 0x% 02x"% l [0]

      # Directly outputs the payload
      print "payload =",
      for c in l [2:]:
      print "% 02x"% c,
      print "(hex)"
      return True

      # 0x81 interpretation of the message
      def printPayload_0x81 (l):
      if len (l) = 23:! return False # check of data size

      ladr = l [5] << 24 | l [6] << 16 | l [7] << 8 | l [8]
      print "command = 0x% 02x (data arrival)"% l [1]
      print "src = 0x% 02x"% l [0]
      print "src long = 0x% 08x"% ladr
      print "dst = 0x% 02x"% l [9]
      print "pktid = 0x% 02x"% l [2]
      print "prtcl ver = 0x% 02x"% l [3]
      print "LQI =% d /% .2f [dbm]"% (l [4], (7 * l [4] -1970) / 20.)
      ts = l [10] << 8 | l [11]
      print "time stmp =% .3f [s]"% (ts / 64.0)
      print "relay flg =% d"% l [12]
      vlt = l [13] << 8 | l [14]
      print "volt =% 04d [mV]"% vlt

      Data of # DI1..4
      dibm = l [16]
      dibm_chg = l [17]
      di = # of the current state
      di_chg = # 1 Once in Lo (1) at least once
      for i in range (1,5):
      di [i] = 0 if (dibm & 0x1) == 0 else 1
      di_chg [i] = 0 if (dibm_chg & 0x1) == 0 else 1
      dibm >> = 1
      dibm_chg >> = 1
      pass

      print "DI1 =% d /% d DI2 =% d /% d DI3 =% d /% d DI4 =% d /% d"% (di [1], di_chg [1], di [2], di_chg [ 2], di [3], di_chg [3], di [4], di_chg [4])

      Data of # AD1..4
      ad =
      er = l [22]
      for i in range (1,5):
      av = l [i + 18 - 1]
      if av == 0xFF:
      # AD and if the port is unused treatment (approximately 2V or more) -1
      ad [i] = -1
      else:
      # Calculation, including the correction bits
      ad [i] = ((av * 4) + (er & 0x3)) * 4
      er >> = 2
      print "AD1 =% 04d AD2 =% 04d AD3 =% 04d AD4 =% 04d [mV]"% (ad [1], ad [2], ad [3], ad [4])

      return True

      # Interpret the data line by line
      while True:
      line = ser.readline (). rstrip () # to read in one line units, and remove the trailing line feed code (blocking read)

      if len (line)> 0 and line [0] == ':':
      print " n% s"% line
      else:
      continue

      try:
      lst = map (ord, line [1:]. decode ('hex')) # convert the HEX string after decoding the string, to each ord and () the list
      csum = sum (lst) & 0xff # checksum if 0 by adding a total of 8bit calculation OK
      lst.pop () remove the # checksum from the list
      if csum == 0:
      if lst [1] == 0x81:
      printPayload_0x81 (lst) # reception of IO-related data
      else:
      printPayload (lst) # Other data reception
      else:
      print "checksum ng"
      except:
      print "skip" # when an error






      text-processing






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 18 at 6:29









      Rui F Ribeiro

      38.2k1475123




      38.2k1475123










      asked Nov 11 '15 at 1:21









      Thomashamka

      85




      85




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          0
          down vote













          In your first sample



          Filter.pl: command not found


          Your shell is not finding the filter.pl script.



          You will need to specify the full path to your script. If it is in the current directory, use ./filter.pl like this:



          /home/USER/Desktop/python/script.py /dev/ttyUSB0 | ./filter.pl >> output.csv





          share|improve this answer




















          • thanks for reply. after I tried that it says "Bash: ./filter.pl: permission denied". CTRL + C and again "Broken pipe". Tried searching but didn't get much help. Got any ideas? Thanks alot.
            – Thomashamka
            Nov 12 '15 at 2:42










          • EDIT: I used chmod or something, now it just says broken pipe after I cancel it with CTRL + C. It's not easy to learn stuff :D
            – Thomashamka
            Nov 12 '15 at 2:50










          • It's normal to get a "broken pipe" message when you terminate a process that is using pipes. Try letting the script run for a while before breaking out with Ctrl-C, then have a look at the contents of your output.csv file and see if it contains what you're looking for.
            – Ian Petts
            Nov 12 '15 at 9:12










          • "Ian, thanks again. I will try it now, is there an possibility to do a real time output to file? As this is an continous loop that cannot be stopped, or can, but it shouldnt be,
            – Thomashamka
            Nov 13 '15 at 2:11










          • I don't know python well enough to give you a confident answer, and you haven't supplied the contents of filter.pl, so this is an assumption, but it should be outputting in real time as is. Open another terminal and do a tail -f output.csv to watch the file get written to in real-time (Ctrl-C to stop watching the file).
            – Ian Petts
            Nov 13 '15 at 2:17


















          up vote
          0
          down vote













          It seems that it was easier than I thought. This is to help people with similar problems.



          In the terminal write



          python3 -u ./file.py | tee ./output.file


          I am now looking how to append and filter using BASH.



          Hopefully this helps someone.



          EDIT: Appending works with "a". after tee, add -a.



          python3 -u ./file.py | tee -a ./output.file





          share|improve this answer






















            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f242269%2fusb-data-logging-ubuntu-mate%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            In your first sample



            Filter.pl: command not found


            Your shell is not finding the filter.pl script.



            You will need to specify the full path to your script. If it is in the current directory, use ./filter.pl like this:



            /home/USER/Desktop/python/script.py /dev/ttyUSB0 | ./filter.pl >> output.csv





            share|improve this answer




















            • thanks for reply. after I tried that it says "Bash: ./filter.pl: permission denied". CTRL + C and again "Broken pipe". Tried searching but didn't get much help. Got any ideas? Thanks alot.
              – Thomashamka
              Nov 12 '15 at 2:42










            • EDIT: I used chmod or something, now it just says broken pipe after I cancel it with CTRL + C. It's not easy to learn stuff :D
              – Thomashamka
              Nov 12 '15 at 2:50










            • It's normal to get a "broken pipe" message when you terminate a process that is using pipes. Try letting the script run for a while before breaking out with Ctrl-C, then have a look at the contents of your output.csv file and see if it contains what you're looking for.
              – Ian Petts
              Nov 12 '15 at 9:12










            • "Ian, thanks again. I will try it now, is there an possibility to do a real time output to file? As this is an continous loop that cannot be stopped, or can, but it shouldnt be,
              – Thomashamka
              Nov 13 '15 at 2:11










            • I don't know python well enough to give you a confident answer, and you haven't supplied the contents of filter.pl, so this is an assumption, but it should be outputting in real time as is. Open another terminal and do a tail -f output.csv to watch the file get written to in real-time (Ctrl-C to stop watching the file).
              – Ian Petts
              Nov 13 '15 at 2:17















            up vote
            0
            down vote













            In your first sample



            Filter.pl: command not found


            Your shell is not finding the filter.pl script.



            You will need to specify the full path to your script. If it is in the current directory, use ./filter.pl like this:



            /home/USER/Desktop/python/script.py /dev/ttyUSB0 | ./filter.pl >> output.csv





            share|improve this answer




















            • thanks for reply. after I tried that it says "Bash: ./filter.pl: permission denied". CTRL + C and again "Broken pipe". Tried searching but didn't get much help. Got any ideas? Thanks alot.
              – Thomashamka
              Nov 12 '15 at 2:42










            • EDIT: I used chmod or something, now it just says broken pipe after I cancel it with CTRL + C. It's not easy to learn stuff :D
              – Thomashamka
              Nov 12 '15 at 2:50










            • It's normal to get a "broken pipe" message when you terminate a process that is using pipes. Try letting the script run for a while before breaking out with Ctrl-C, then have a look at the contents of your output.csv file and see if it contains what you're looking for.
              – Ian Petts
              Nov 12 '15 at 9:12










            • "Ian, thanks again. I will try it now, is there an possibility to do a real time output to file? As this is an continous loop that cannot be stopped, or can, but it shouldnt be,
              – Thomashamka
              Nov 13 '15 at 2:11










            • I don't know python well enough to give you a confident answer, and you haven't supplied the contents of filter.pl, so this is an assumption, but it should be outputting in real time as is. Open another terminal and do a tail -f output.csv to watch the file get written to in real-time (Ctrl-C to stop watching the file).
              – Ian Petts
              Nov 13 '15 at 2:17













            up vote
            0
            down vote










            up vote
            0
            down vote









            In your first sample



            Filter.pl: command not found


            Your shell is not finding the filter.pl script.



            You will need to specify the full path to your script. If it is in the current directory, use ./filter.pl like this:



            /home/USER/Desktop/python/script.py /dev/ttyUSB0 | ./filter.pl >> output.csv





            share|improve this answer












            In your first sample



            Filter.pl: command not found


            Your shell is not finding the filter.pl script.



            You will need to specify the full path to your script. If it is in the current directory, use ./filter.pl like this:



            /home/USER/Desktop/python/script.py /dev/ttyUSB0 | ./filter.pl >> output.csv






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 11 '15 at 5:14









            Ian Petts

            1573




            1573











            • thanks for reply. after I tried that it says "Bash: ./filter.pl: permission denied". CTRL + C and again "Broken pipe". Tried searching but didn't get much help. Got any ideas? Thanks alot.
              – Thomashamka
              Nov 12 '15 at 2:42










            • EDIT: I used chmod or something, now it just says broken pipe after I cancel it with CTRL + C. It's not easy to learn stuff :D
              – Thomashamka
              Nov 12 '15 at 2:50










            • It's normal to get a "broken pipe" message when you terminate a process that is using pipes. Try letting the script run for a while before breaking out with Ctrl-C, then have a look at the contents of your output.csv file and see if it contains what you're looking for.
              – Ian Petts
              Nov 12 '15 at 9:12










            • "Ian, thanks again. I will try it now, is there an possibility to do a real time output to file? As this is an continous loop that cannot be stopped, or can, but it shouldnt be,
              – Thomashamka
              Nov 13 '15 at 2:11










            • I don't know python well enough to give you a confident answer, and you haven't supplied the contents of filter.pl, so this is an assumption, but it should be outputting in real time as is. Open another terminal and do a tail -f output.csv to watch the file get written to in real-time (Ctrl-C to stop watching the file).
              – Ian Petts
              Nov 13 '15 at 2:17

















            • thanks for reply. after I tried that it says "Bash: ./filter.pl: permission denied". CTRL + C and again "Broken pipe". Tried searching but didn't get much help. Got any ideas? Thanks alot.
              – Thomashamka
              Nov 12 '15 at 2:42










            • EDIT: I used chmod or something, now it just says broken pipe after I cancel it with CTRL + C. It's not easy to learn stuff :D
              – Thomashamka
              Nov 12 '15 at 2:50










            • It's normal to get a "broken pipe" message when you terminate a process that is using pipes. Try letting the script run for a while before breaking out with Ctrl-C, then have a look at the contents of your output.csv file and see if it contains what you're looking for.
              – Ian Petts
              Nov 12 '15 at 9:12










            • "Ian, thanks again. I will try it now, is there an possibility to do a real time output to file? As this is an continous loop that cannot be stopped, or can, but it shouldnt be,
              – Thomashamka
              Nov 13 '15 at 2:11










            • I don't know python well enough to give you a confident answer, and you haven't supplied the contents of filter.pl, so this is an assumption, but it should be outputting in real time as is. Open another terminal and do a tail -f output.csv to watch the file get written to in real-time (Ctrl-C to stop watching the file).
              – Ian Petts
              Nov 13 '15 at 2:17
















            thanks for reply. after I tried that it says "Bash: ./filter.pl: permission denied". CTRL + C and again "Broken pipe". Tried searching but didn't get much help. Got any ideas? Thanks alot.
            – Thomashamka
            Nov 12 '15 at 2:42




            thanks for reply. after I tried that it says "Bash: ./filter.pl: permission denied". CTRL + C and again "Broken pipe". Tried searching but didn't get much help. Got any ideas? Thanks alot.
            – Thomashamka
            Nov 12 '15 at 2:42












            EDIT: I used chmod or something, now it just says broken pipe after I cancel it with CTRL + C. It's not easy to learn stuff :D
            – Thomashamka
            Nov 12 '15 at 2:50




            EDIT: I used chmod or something, now it just says broken pipe after I cancel it with CTRL + C. It's not easy to learn stuff :D
            – Thomashamka
            Nov 12 '15 at 2:50












            It's normal to get a "broken pipe" message when you terminate a process that is using pipes. Try letting the script run for a while before breaking out with Ctrl-C, then have a look at the contents of your output.csv file and see if it contains what you're looking for.
            – Ian Petts
            Nov 12 '15 at 9:12




            It's normal to get a "broken pipe" message when you terminate a process that is using pipes. Try letting the script run for a while before breaking out with Ctrl-C, then have a look at the contents of your output.csv file and see if it contains what you're looking for.
            – Ian Petts
            Nov 12 '15 at 9:12












            "Ian, thanks again. I will try it now, is there an possibility to do a real time output to file? As this is an continous loop that cannot be stopped, or can, but it shouldnt be,
            – Thomashamka
            Nov 13 '15 at 2:11




            "Ian, thanks again. I will try it now, is there an possibility to do a real time output to file? As this is an continous loop that cannot be stopped, or can, but it shouldnt be,
            – Thomashamka
            Nov 13 '15 at 2:11












            I don't know python well enough to give you a confident answer, and you haven't supplied the contents of filter.pl, so this is an assumption, but it should be outputting in real time as is. Open another terminal and do a tail -f output.csv to watch the file get written to in real-time (Ctrl-C to stop watching the file).
            – Ian Petts
            Nov 13 '15 at 2:17





            I don't know python well enough to give you a confident answer, and you haven't supplied the contents of filter.pl, so this is an assumption, but it should be outputting in real time as is. Open another terminal and do a tail -f output.csv to watch the file get written to in real-time (Ctrl-C to stop watching the file).
            – Ian Petts
            Nov 13 '15 at 2:17













            up vote
            0
            down vote













            It seems that it was easier than I thought. This is to help people with similar problems.



            In the terminal write



            python3 -u ./file.py | tee ./output.file


            I am now looking how to append and filter using BASH.



            Hopefully this helps someone.



            EDIT: Appending works with "a". after tee, add -a.



            python3 -u ./file.py | tee -a ./output.file





            share|improve this answer


























              up vote
              0
              down vote













              It seems that it was easier than I thought. This is to help people with similar problems.



              In the terminal write



              python3 -u ./file.py | tee ./output.file


              I am now looking how to append and filter using BASH.



              Hopefully this helps someone.



              EDIT: Appending works with "a". after tee, add -a.



              python3 -u ./file.py | tee -a ./output.file





              share|improve this answer
























                up vote
                0
                down vote










                up vote
                0
                down vote









                It seems that it was easier than I thought. This is to help people with similar problems.



                In the terminal write



                python3 -u ./file.py | tee ./output.file


                I am now looking how to append and filter using BASH.



                Hopefully this helps someone.



                EDIT: Appending works with "a". after tee, add -a.



                python3 -u ./file.py | tee -a ./output.file





                share|improve this answer














                It seems that it was easier than I thought. This is to help people with similar problems.



                In the terminal write



                python3 -u ./file.py | tee ./output.file


                I am now looking how to append and filter using BASH.



                Hopefully this helps someone.



                EDIT: Appending works with "a". after tee, add -a.



                python3 -u ./file.py | tee -a ./output.file






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 17 '15 at 4:19

























                answered Nov 17 '15 at 4:14









                Thomashamka

                85




                85



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f242269%2fusb-data-logging-ubuntu-mate%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown






                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay