Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

While gnome terminal shows output of below command, it doesn't pipe it out to text file

 xinput test 5 

shows output in terminal but

 xinput test 5 >> text.txt 

doesn't pipe out to file

EDIT:

"xinput test 5" shows key codes of virtual keyboard. I can see output in terminal with " xinput test 5" but not with "xinput test 5 >>text.txt

It shows keycodes from onboard.

EDIT2:

I want to record keystrokes of "onboard" to file "xinput test 5" shows the keystroke IDs well in terminal but it doesn't save it to file with " xinput test 5 >> text.txt " it also prevents showing keystroke IDs in terminal. "xinput test 5 2>>text.txt" shows output in terminal but doesn't pipe it out to text file.

EDIT3:

You can find virtual keyboard ID with "xinput list" Interestingly can see output in terminal with " xinput test 5" but not with "xinput test 5 >>text.txt

share|improve this question
3  
What should be the output of xinput test 5? I don't get any output. –  i08in Dec 23 '13 at 10:35
    
@kenn xinput test 5 does not give any output on my system. Please clarify on what you expect to happen. Without any output your shell will not redirect any, so you may think it's not working. –  gertvdijk Dec 23 '13 at 10:42
    
"xinput test 5" shows key codes of virtual keyboard. –  kenn Dec 23 '13 at 10:42
    
@kenn No it doesn't. As far as I can see, for me, it just blocks and local-echoes stuff you type. –  gertvdijk Dec 23 '13 at 11:54
    
How? I didn't get what you mean. It shows like key press 36 key release 36 key press 57 key release 57 –  kenn Dec 23 '13 at 11:59
add comment

3 Answers 3

up vote 2 down vote accepted

The output is buffered, so nothing goes to the file until the writer (xinput) flushes it.
To force unbuffered output you can use

stdbuf -o0 xinput test 5 >out
share|improve this answer
    
Wow, here is the master! Thank you enzotib. I'm grateful for the info you shared. It works. –  kenn Dec 23 '13 at 11:39
add comment

Oddly, redirecting does work normally (I've just tested this with my mouse)... It seems to be a problem specific to the virtual device.

Well this was a much bigger, stranger problem than I initially thought. The short answer is: it's buffered and when you Control+C, that buffer is lost. Now, I have no idea why it's being buffered for the virtual device and not physical ones.... That's above my pay grade.

How to work around it is pretty simple though (again from Stephane Chazelas at Unix & Linux):

stdbuf -oL xinput test 5 > test

And the reason you were seeing some output before is because they virtual keyboard writes to the active window (like a physical keyboard would).

share|improve this answer
    
@kenn Sorry for jumping the gun there. The command seems to have a fairly large quirk. –  Oli Dec 23 '13 at 11:39
    
I've just seen your answer. I'm grateful for all your help. I saw his post earlier. I'm sorry. You knew the answer too. –  kenn Dec 23 '13 at 11:49
add comment

Try this,

xinput test 5 > text.txt
share|improve this answer
    
nope, it doesn't work. I already tried that. –  kenn Dec 23 '13 at 10:20
    
what was the output of xinput test 5? –  Avinash Raj Dec 23 '13 at 10:21
    
"xinput test 5" shows key codes of virtual keyboard. –  kenn Dec 23 '13 at 10:33
2  
edit the question and then post the output of xinput test 5. –  Avinash Raj Dec 23 '13 at 10:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.