about pipes
- From: Christophe Maquaire <christophe.maquaire.toomuchhere@xxxxxxxxxxxxxxxxx>
- Date: Mon, 19 Mar 2007 12:15:50 +0100
Hello,
I need your help, but I'm not a shell guru and i need hours for some
lines...So keep cool and speak slowly!
I have to wait text lines from /dev/ttyS0 and to store them in files.
# cat /dev/ttyS0 >> /home/christophe/alarme/$(date +%Y_%m)
Does what i want.
So i write a small script
#! /bin/sh
echo "emulation imprimante"
cat /dev/ttyS0 >> /home/christophe/alarme/$(date +%Y_%m) &
in my /etc/init.d called by rcS.d and all is fine.
But lines looks like this:
05 fev 14:33 SY
^M01 Action 002 code R2
^M05 fev 14:33 SY
^M07 Action 002 code R2
^M05 fev 14:33 G1
^M001 Marche Action 01
^M05 fev 14:34 G3
^M001 Marche Action 01
So, i want to remove ^M and get one line for two :
05 fev 14:33 SY 01 Action 002 code R2
05 fev 14:33 SY 07 Action 002 code R2
05 fev 14:33 G1 001 Marche Action 01
05 fev 14:34 G3 001 Marche Action 01
# cat /home/christophe/alarme/2007_02 | sed -e 's/[^M]/ /' | awk '{ if
(match($0,":")) printf "%s ", $0; else printf "%s\n", $0 }' >>
/home/christophe/alarme/$(date +%Y_%m)
seems working, so i try my new script in /etc/init.d
#! /bin/sh
echo "emulation imprimante"
cat /dev/ttyS0 | sed -e 's/[^M]/ /' | awk '{ if(match($0,":")) printf
"%s", $0; else printf "%s\n", $0 }' >> /home/christophe/alarme/$(date
+%Y_%m)>> /home/christophe/alarme/$(date +%Y_%m) &
and I get nothing...
Now, I need your help !
Thanks,
Christophe
.
- Follow-Ups:
- Re: about pipes
- From: Janis
- Re: about pipes
- From: Christophe Maquaire
- Re: about pipes
- Prev by Date: Re: copy files greater than 40 kb size from a folder using single command
- Next by Date: help with ftp script
- Previous by thread: can someone please test this shell snippet for me?
- Next by thread: Re: about pipes
- Index(es):