-1

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
ALi
  • 1
  • 1
  • 2
    You mean it hangs, or does it do nothing and give you a command prompt back? – lurker Nov 01 '15 at 02:43
  • 1
    Break it into parts: try one command at a time and tell us which command it is that is giving you trouble. P.S. You need a semicolon before the final `echo` command. – John1024 Nov 01 '15 at 02:59
  • The part when Essid is being set as a variable, has the issue. airodump-ng wlan1 it's not being piped through all the way – ALi Nov 01 '15 at 10:51

1 Answers1

1

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.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278