![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Accessing variables of one shell script in another shell script | rsendhilmani | Shell Programming and Scripting | 2 | 03-17-2009 01:17 AM |
| Script to Scan proclog files | deeprajn95 | Shell Programming and Scripting | 3 | 05-12-2008 07:25 AM |
| Perl script to scan back lines | gholdbhurg | Shell Programming and Scripting | 3 | 03-18-2008 12:33 PM |
| Perl script to scan through files | gholdbhurg | Shell Programming and Scripting | 1 | 03-05-2008 10:53 PM |
| port scan shell script | nrbhole | Shell Programming and Scripting | 3 | 01-31-2008 11:28 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
hcitool scan via shell script
Hello, Im new to shell scripting , and i have the following question . The hcitool scan command returns the bluetooth address of the phone . When it is run the output is something like Code:
Scanning....
00:A1:5D:AB:B2:E9 Nokia 6600
Can i get the output in a varaiable in a shell script ? I tried redirecting the output to a file, as follows Code:
hcitool scan > addr But the file only recorded "Scanning....". The remaining part was not saved. Please help. Thanks. Last edited by rahulkhn; 07-15-2008 at 09:02 PM.. |
|
||||
|
Maybe the second bit of output is sent to stderr instead of stdout? Try hcitool scan > addr 2>&1. If that works, use this to get it into a variable: Code:
addr=$(hcitool scan 3>&1 >/dev/null 2>&3 | awk '{print $1}')
The 3>&1 part copies file descriptor 1 (stdout) to a new file descriptor 3. >/dev/null discards stdout, and then 2>&3 redirects stderr to the new file descriptor. This means that the awk process which is next in the pipeline can read from stdin what would previously have gone to stderr. Last edited by Annihilannic; 07-15-2008 at 10:19 PM.. Reason: typo |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|