awk error awk: line 2: missing } near end of file
Hi, please can anyone give me some help here
I am trying to do a if stament using awk but I keep having this error awk: line 2: missing } near end of file and this is the part of the code echo "$scanning_card_signal_quality $ROAMING_THRESHOLD_WLAN0 $connected_card_signal_quality" | awk '{if (($1 > $2) && ($3 < $2)) {' echo "Starting handover from $connected_card to $scanning_card" start_handover=$(date +%s.%N) sudo iwconfig $scanning_card essid 'HTC network' end_handover=$(date +%s.%N) time_delay=$(echo "$end_handover - $start_handover" | bc) echo "Handover time delay is $time_delay nanoseconds" # sudo dhclient $WLAN0 sudo dhclient $connected_card # sudo ip addr add 192.168.1.136/24 dev $scanning_card sudo ping -c4 google.com #ping command to check the connection echo "line 64" #sudo ip link set down $connected_card sudo dhclient -r $connected_card sudo ip link set up $connected_card temp=$connected_card connected_card=$scanning_card scanning_card=$temp'}' AND THIS IN THE ENTIRE CODE #!/bin/sh -ux clear echo "This script control the wireless interface during handover" echo sleep 2 connected_card="wlan0" scanning_card="wlan1" echo "Starting wireless interface one" sleep 2 sudo ip link set $connected_card down sudo dhclient -r $connected_card sudo ip link set $connected_card up echo "$connected_card is scanning the network" sudo iwconfig $connected_card | grep level echo "line 19" #echo "Connecting $connected_card to a network with highest signal "$ACCESS_POINT_HIGHSIG1 # will replace the above command for test #sudo iw $connected_card connect 'HTC network' sudo iwconfig $connected_card essid 'HTC network' echo "$connected_card is connected" # connected_card=$WLAN0 echo "$connected_card is getting an ip address" sudo dhclient $connected_card #sudo ip addr add 192.168.1.136/24 dev $connected_card echo "Now trying to ping google.com this might take some time" sudo ping -c4 google.com #ping command to check the connection sleep 2 echo "Starting the wireless interface $scanning_card" sudo ifconfig $scanning_card up sudo ip link set $scanning_card up # scanning_card=$WLAN1 ROAMING_THRESHOLD_WLAN1=40/100 # placing a roaming threshold or trigger for handover ROAMING_THRESHOLD_WLAN0=`awk 'BEGIN{printf("%0.2f", 20/70 )}'` while [ 1 ] do #scanning for access point with better signal access_point_highest_sig=`sudo iwlist $scanning_card scan | egrep 'ESSID|Quality' | sort -r | grep ESSID | head -1 | cut -f2 -d:` scanning_card_signal_quality=`sudo iwlist $scanning_card scan | grep 'Quality' | sort -m | head -1 | awk '{print $1}' | cut -f2 -d=` connected_card_signal_quality=`sudo iwlist $connected_card scan | grep 'Quality' | sort -m | head -1 | awk '{print $1}' | cut -f2 -d=` scanning_card_signal_quality=`awk 'BEGIN{printf("%0.2f", '$scanning_card_signal_quality' )}'` connected_card_signal_quality=`awk 'BEGIN{printf("%0.2f", '$connected_card_signal_quality' )}'` # display access point with better signal and the access point itself echo "$scanning_card signal quality $scanning_card_signal_quality is scanning" echo "$connected_card signal quality $connected_card_signal_quality is connected" echo "Access point returned by wlan1 with highest signal $access_point_highest_sig" # sleep 3 echo "$scanning_card_signal_quality $ROAMING_THRESHOLD_WLAN0 $connected_card_signal_quality" | awk '{if (($1 > $2) && ($3 < $2)) {' echo "Starting handover from $connected_card to $scanning_card" start_handover=$(date +%s.%N) sudo iwconfig $scanning_card essid 'HTC network' end_handover=$(date +%s.%N) time_delay=$(echo "$end_handover - $start_handover" | bc) echo "Handover time delay is $time_delay nanoseconds" # sudo dhclient $WLAN0 sudo dhclient $connected_card # sudo ip addr add 192.168.1.136/24 dev $scanning_card sudo ping -c4 google.com #ping command to check the connection echo "line 64" #sudo ip link set down $connected_card sudo dhclient -r $connected_card sudo ip link set up $connected_card temp=$connected_card connected_card=$scanning_card scanning_card=$temp'}' done |
why have you posted all of that crap when it's clearly an error in the awk command?
Code:
awk '{if (($1 > $2) && ($3 < $2)) {' If sounds like you're trying to use awk to make an "if then else" statement outside of it's own scope or something... very odd. Remove the awk and do it with proper bash instead. |
Useful post questions should include only details relevant to your problem, not just a giant dump of everything you have.
Nobody wants to take the time to read through a mess of text to locate your errors for you, so take some time to cut it down to the section or commands that relate directly to the problem at hand. Who knows, you might discover where you went wrong in the process on your own while you're at it. Please read How To Ask Questions The Smart Way, for more tips on how to get the most out of help forums like this. Also, when you post, please use [code][/code] tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting. |
All times are GMT -5. The time now is 05:05 PM. |