1

Total noob here. I am blindly stumbling my way through bash. I realize that there is a syntax error in the following script but, I cannot figure it out. The script just sits there.

#!/bin/bash

mac=`tail -F ~/scripts/scan.txt | grep -i "IP:" | cut -d "(" -f2 | cut -d ")" -f1` 

sudo dhcpdump -i wlan0 > ~/scripts/scan.txt
echo $mac

Thanks for any help. I am gonna feel like an idiot when I find out.

3
  • 1
    What are you trying to do, exactly? the -F option of tail is probably not something you want in a variable assignment as it as it will block waiting for bytes to be appended to the file. May 12, 2015 at 14:07
  • Also change the order of lines, in the first line you are reading a file that does not exist yet (probably, as per script)..it will be generated by the second line (if not exist already)..
    – heemayl
    May 12, 2015 at 14:10
  • What is the content of ~/scripts/scan.txt? Give me a ping with @A.B.
    – A.B.
    May 12, 2015 at 17:13

1 Answer 1

0

Firstly, scan.txt is being continually monitored by scan -F, which never quits. Secondly, grep "IP:" fails - try "IP" instead, & thirdly you're generating the scan.txt file after you've checked it..

You'd need to have the dhcpdump line running as a timed process to make the first program line do anything at all.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .