You are not logged in.

#1 2007-03-07 00:55:38

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

seek a file in bash?

I have serial device /dev/ttyS0 that I need to read the first byte from. Using cat /dev/ttyS0 will not return me to a new line which is what I need. I'm sure there's simple command for it but I can't find it..

EDIT: I believe in perl it went something like

sysread(F2, '/dev/ttyS0', 1)

Offline

#2 2007-03-07 01:12:24

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: seek a file in bash?

Use 'dd'?


1000

Offline

#3 2007-03-07 01:16:29

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: seek a file in bash?

dd is what you want.... as a guess

dd if=/dev/ttyS0 count=1

hmmm actually that gives me an input/output error... not sure why, but dd should do what you want assuming you can read the node.

Offline

#4 2007-03-08 04:23:39

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: seek a file in bash?

thanks guys

status=$(dd if=/dev/ttyS0 bs=1 count=1 2>/dev/null)

worked like a charm smile

Offline

Board footer

Powered by FluxBB