You are not logged in.

#1 2012-10-21 12:24:30

sakishrist
Member
Registered: 2012-03-04
Posts: 42

[SOLVED] Flush remaining data of character device

Hello all,

I was wandering how I could flush the remaining data of a character device from a terminal.

Thanks in advance

Last edited by sakishrist (2012-10-25 11:08:25)

Offline

#2 2012-10-21 15:47:24

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: [SOLVED] Flush remaining data of character device

dd if=/dev/whatever of=/dev/null ?

Offline

#3 2012-10-22 12:08:07

sakishrist
Member
Registered: 2012-03-04
Posts: 42

Re: [SOLVED] Flush remaining data of character device

I have a virtual machine with a login prompt set to spawn on a serial port.

This way I could send a some commands to the virtual machine. The problem though was that when I was reading the response, it could contain data previously sent through the port. So I would get multiple replies if I did something like this:

# echo "uname" > /dev/pts/2 
# echo "date" > /dev/pts/2
# cat /dev/pts/2
Linux
Mon Oct 22 14:52:26 EEST 2012

I was wandering if there is a simple way (non blocking, unlike dd) to get only the last result. Something like:

# do_something_to_flush /dev/pts/2

But today, I have a different problem. There is no data kept at all in /dev/pts/2. I get nothing when I do:

# echo "date" > /dev/pts/2
# cat /dev/pts/2

I have to type cat in one terminal and send the command through another to get results. I am really baffled by this change overnight.

Thanks in advance

Offline

#4 2012-10-22 15:09:35

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: [SOLVED] Flush remaining data of character device

dd has a "nonblock" option to turn off blocking I/O.

As for your new issue, I have no idea, and I especially don't know why it would behave differently when run from a different shell.

Offline

Board footer

Powered by FluxBB