hcitool scan via shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting hcitool scan via shell script
# 1  
Old 07-15-2008
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..
# 2  
Old 07-15-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to scan the disks and make file system

Hi What I'm trying to do(manually) is logging into the server and running the below mentioned commands ls /sys/class/scsi_device/ | while read i; do echo "- - -" > /sys/class/scsi_device/$i/device/rescan;done lsblk echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/sdd partx -a /dev/sdd1... (7 Replies)
Discussion started by: James0806
7 Replies

2. Shell Programming and Scripting

How to write script to scan ip list through Nessus?

Scripting language: Shell script I want to Scan IP's from IPlist.txt through Nessus using shell scripting language. Give the Input (IPlist) to nessus and generate Nessus report in xml or PDF form which is saved automatically on computer . Please help if any one has idea about how to write... (2 Replies)
Discussion started by: sk151993
2 Replies

3. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

A script to scan a directory for XML files,

Hi, I am fairly new to unix/linux scripting (about 1 week) and have written a script to scan a directory for xml files, if found call and oracle procedure passing in the file name and then move the file once processed to an archive area. Now everything seems to be working except when there... (3 Replies)
Discussion started by: apacheuk
3 Replies

5. Shell Programming and Scripting

Shell Script to continuously scan a log file

Hello members, I have some doubts on how to write a script that can reports success / failure of a batch job ? 1. Run a batch job: 2. Wait and search for a particular string in the Log file: tail -f log01*.txt | egrep -v "^SUCCESSFUL" echo "continue with the other tasks" ... (1 Reply)
Discussion started by: novice82
1 Replies

6. Shell Programming and Scripting

How to scan data directly from Table using a script

Hi, I have a new task where i have two tables Acct_ open and lookup table In the Acct_open table there is all the information about an account including account number and lookup table is having a country code and corresponding country name where that account has been opened. both... (2 Replies)
Discussion started by: manmeet
2 Replies

7. Shell Programming and Scripting

Script to Scan proclog files

i need to create a shell script, which will go into a directory , and scan the files in it for defined errors, there will be around 10 files in the directory. (3 Replies)
Discussion started by: deeprajn95
3 Replies

8. Shell Programming and Scripting

Perl script to scan back lines

Hi Perl gurus, I have this file to scan through. Sample lines below: 2008031A, USERNAME, 12345, give ABC, take XYZ, transaction submitted 2008031B, USERNAME, 12346, waiting for processing 2008031C, USERNAME, 12347, Retrieving response 2008031D, USERNAME, 12348, This is not a valid dealing... (3 Replies)
Discussion started by: gholdbhurg
3 Replies

9. Shell Programming and Scripting

Perl script to scan through files

Dear perl gurus, I plan to create a script that will scan through a logfile line by line. And if ever a certain line meets the below conditions, it will alert me via email. --> a) Position 10 to 13 = "ABCD" b) And also if the amount specified in position 620-640 is less than the amount in... (1 Reply)
Discussion started by: gholdbhurg
1 Replies

10. Shell Programming and Scripting

port scan shell script

Hi, Can any one please suggest me commands for making port scan shell script. (3 Replies)
Discussion started by: nrbhole
3 Replies
Login or Register to Ask a Question