LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-03-2013, 07:01 AM   #1
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Rep: Reputation: 142Reputation: 142
Can't get evtest output into variable


Hi!
I'm trying to read evtest output into variable for next usage (parsing).
Code:
#!/bin/bash
while true; do
EVENT=`evtest /dev/input/event0 | grep "LEFT"`
echo "$EVENT"
done
Code hangs on EVENT=`evtest /dev/input/event0 | grep "LEFT"` command.

if I print the output immediately it works and shows output:
Code:
#!/bin/bash
while true; do
echo evtest /dev/input/event0 | grep "LEFT"
done
How can I get it into variable?
Thanks in advance.
 
Old 05-03-2013, 07:35 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
evtest monitors /dev/input/event0, so in the first case it probably never returns. Probably you can try:
EVENT=`evtest /dev/input/event0 | head -1 | grep "LEFT"` or similar, but I'm not really sure about the result. Maybe you should write a small script.
In your second case evtest will not run at all.
 
Old 05-03-2013, 08:52 AM   #3
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 616

Original Poster
Rep: Reputation: 142Reputation: 142
thanks for reply!
I tried to use evtest piping with head, but it can give me only the first 'n' lines. But I need the last line of output only. Also I tried to use 'tail' but 'tail' can't read from /dev/input/event0.
Also I tried to use evtest-capture (writes output to file) and read it's output by tail. It works, but I got a huge latency and it totally unuseable.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
touchscreen and evtest linux.omicron Linux - Laptop and Netbook 0 02-07-2013 12:44 PM
[SOLVED] output to a variable in while loop Leath Linux - Newbie 10 07-29-2012 10:32 AM
evtest for the keyboard to monitor ? patrick295767 Linux - General 1 05-21-2012 01:36 PM
[SOLVED] Bash; awk or sed output to variable: how keep newline at end of each output line porphyry5 Programming 3 06-10-2011 05:50 PM
evtest slackware10.1 compiling issue aikidoist72 Slackware 0 07-10-2005 09:12 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration