Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > Debian Linux > Debian Linux support

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-25-2008, 12:37 AM
Henk Oegema
 
Posts: n/a
Default which command(s) to use ?

I want to read a certain value from a usb device printout, like this:

asterisk:/proc# k8055 -m:1
Velleman Device Found @ Address 018 Vendor 0x010cf Product ID 0x05500
get driver name: could not get bound driver: No data available
Found interface 0
Took over the device
232;0;119;132;2;1


The value I'm interested in is the last line
232;0;119;132;2;1
and then the second value (in this case 0)

I've been trying with the 'cut' command. But I don't know how to pick out
only the last line.
May be I need another approach. (?)

rgds
Henk




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-25-2008, 12:37 AM
Johnny Rebel
 
Posts: n/a
Default Re: which command(s) to use ?

Henk Oegema wrote:
> I want to read a certain value from a usb device printout, like this:
>
> asterisk:/proc# k8055 -m:1
> Velleman Device Found @ Address 018 Vendor 0x010cf Product ID 0x05500
> get driver name: could not get bound driver: No data available
> Found interface 0
> Took over the device
> 232;0;119;132;2;1
>
>
> The value I'm interested in is the last line
> 232;0;119;132;2;1
> and then the second value (in this case 0)
>
> I've been trying with the 'cut' command. But I don't know how to pick out
> only the last line.
> May be I need another approach. (?)
>
> rgds
> Henk
>
>
>
>

Not sure how clean this would be for your purpose, but for the 'last' of
something I sometimes do something like this:

for line in `cat /etc/passwd`; do
:
done;
echo $line;


Will give you the last line of /etc/passwd.... The easier way
would be a `tail -1` - not as expensive as the loop....except that in
the loop, you could also grab your second line.

JR.



--

Bill will have to take Linux from my cold, dead flippers.

-Tux.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-25-2008, 12:37 AM
Henk Oegema
 
Posts: n/a
Default Re: which command(s) to use ?

Johnny Rebel wrote:

> Not sure how clean this would be for your purpose, but for the 'last' of
> something I sometimes do something like this:
>
> for line in `cat /etc/passwd`; do
> :
> done;
> echo $line;
>
>
> Will give you the last line of /etc/passwd.... The easier way
> would be a `tail -1` - not as expensive as the loop....except that in
> the loop, you could also grab your second line.
>


I've been trying to 'pipe' to output with different options of tail, but it
always prints all lines.

asterisk:~# k8055 -m:1 | tail -n-1
Velleman Device Found @ Address 018 Vendor 0x010cf Product ID 0x05500
get driver name: could not get bound driver: No data available
Found interface 0
Took over the device
306;0;118;132;2;1
asterisk:~#
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-25-2008, 12:37 AM
Henk Oegema
 
Posts: n/a
Default Re: which command(s) to use ?

Henk Oegema wrote:

The problem is solved.

When I do a
asterisk:/home/henkoegema# k8055 -m:1
is shows:
Velleman Device Found @ Address 018 Vendor 0x010cf Product ID 0x05500
get driver name: could not get bound driver: No data available
Found interface 0
Took over the device
225;0;119;132;2;1

When I do
asterisk:/home/henkoegema# k8055 -m:1 > test

it only shows
225;0;119;132;2;1
in the file.



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-25-2008, 12:37 AM
Henk Oegema
 
Posts: n/a
Default Re: which command(s) to use ?

Henk Oegema wrote:

> Henk Oegema wrote:
>
> The problem is solved.
>
> When I do a
> asterisk:/home/henkoegema# k8055 -m:1
> is shows:
> Velleman Device Found @ Address 018 Vendor 0x010cf Product ID 0x05500
> get driver name: could not get bound driver: No data available
> Found interface 0
> Took over the device
> 225;0;119;132;2;1
>
> When I do
> asterisk:/home/henkoegema# k8055 -m:1 > test
>
> it only shows
> 225;0;119;132;2;1
> in the file.


The only disadvantage is that I have to create a file first.
Can't the value 0 (in the line 225;0;119;132;2;1) be assigned directly to a
bash variable ? (without reading it from a file)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-25-2008, 12:37 AM
=?iso-8859-1?b?Qmr2cm4=?= Steinbrink
 
Posts: n/a
Default Re: which command(s) to use ?

On Sun, 24 Feb 2008 21:55:00 +0100, Henk Oegema wrote:

> Henk Oegema wrote:
>
> The problem is solved.
>
> When I do a
> asterisk:/home/henkoegema# k8055 -m:1 is shows:
> Velleman Device Found @ Address 018 Vendor 0x010cf Product ID 0x05500
> get driver name: could not get bound driver: No data available Found
> interface 0
> Took over the device
> 225;0;119;132;2;1
>
> When I do
> asterisk:/home/henkoegema# k8055 -m:1 > test
>
> it only shows
> 225;0;119;132;2;1
> in the file.


Probably the first few lines go to stderr. I'd try:

k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-25-2008, 01:22 PM
Henk Oegema
 
Posts: n/a
Default Re: which command(s) to use ?

Björn Steinbrink wrote:

> Probably the first few lines go to stderr. I'd try:
>
> k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2


Yes Björn, this gives me the wanted output.

See:
asterisk:/home/henkoegema# k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2
0 <--------
asterisk:/home/henkoegema#

One of my mistakes in the 'cut' command was d: i.s.o. d';'

Only one step left now:
How can I assign the output to a bash variable ?


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-25-2008, 01:22 PM
Johnny Rebel
 
Posts: n/a
Default Re: which command(s) to use ?

Henk Oegema wrote:
> Björn Steinbrink wrote:
>
>> Probably the first few lines go to stderr. I'd try:
>>
>> k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2

>
> Yes Björn, this gives me the wanted output.
>
> See:
> asterisk:/home/henkoegema# k8055 -m:1 2>/dev/null | tail -1 | cut -d';' -f2
> 0 <--------
> asterisk:/home/henkoegema#
>
> One of my mistakes in the 'cut' command was d: i.s.o. d';'
>
> Only one step left now:
> How can I assign the output to a bash variable ?
>
>



var=`<command>`

Put var= in front of it, and use back-ticks around the whole thing.
This will assign the value of it to the var.

JR.

--

Bill will have to take Linux from my cold, dead flippers.

-Tux.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-25-2008, 01:22 PM
Henk Oegema
 
Posts: n/a
Default Re: which command(s) to use ?

Johnny Rebel wrote:

> var=`<command>`
>
> Put var= in front of it, and use back-ticks around the whole thing.
> This will assign the value of it to the var.
>

Thanks Johnny.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-26-2008, 02:31 AM
Johnny Rebel
 
Posts: n/a
Default Re: which command(s) to use ?

Henk Oegema wrote:
> Johnny Rebel wrote:
>
>> var=`<command>`
>>
>> Put var= in front of it, and use back-ticks around the whole thing.
>> This will assign the value of it to the var.
>>

> Thanks Johnny.


No problems, glad to help!

JR.

--

Bill will have to take Linux from my cold, dead flippers.

-Tux.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 07:57 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62