I am writing this script, but it does nothing other than blink the cursor
ifconfig wlan1 down && iwconfig wlan1 mode monitor; Essid=`airodump-ng wlan1 2>&1 | grep 38:EF:A5:8B:5D:85 | awk '{print $11}' ` echo $Essid
I am writing this script, but it does nothing other than blink the cursor
ifconfig wlan1 down && iwconfig wlan1 mode monitor; Essid=`airodump-ng wlan1 2>&1 | grep 38:EF:A5:8B:5D:85 | awk '{print $11}' ` echo $Essid
If it is all written on one line as shown in the question, the echo
is run with a funny environment variable (Essid
, set to the result of a command), but it echoes nothing because the environment variable isn't set when the argument list is evaluated. (See Bash: Specifying environment variables for echo
on the command line for more information.)
If you are sane and write it on multiple lines, then you're in with a decent chance:
ifconfig wlan1 down && iwconfig wlan1 mode monitor
Essid=$(airodump-ng wlan1 2>&1 | grep 38:EF:A5:8B:5D:85 | awk '{print $11}')
echo $Essid
Now you have a decent chance of it working as expected. Note that if the ifconfig
command fails to take wlan1
down, then it won't be brought back up with the iwconfig
command (or ifconfig
command if that's a typo in the question).
Remember: 'one-liner' is a pejorative term unless you're writing in APL. The shell is not APL.