Bash string variable won't pass value -
if last pipe removed, seems value pass , things work until connection no longer active. value goes empty or null double quote still there. sed command can strip pipe won't let value afterwards passed. i'm stuck.
iwgetid wlan0 | grep 'essid:' | cut -c 18-24 | wtf=$(echo "$1" [[ -z "$1" ]] && echo -e "wi-fi not connected!" || echo -e "connected"
anything on right-hand side of pipeline run in subshell, meaning assignments done there aren't visible anywhere else in shell.
also, $1
unclear here -- values wtf
aren't getting positional arguments you're doing. fixing that:
wtf=$(iwgetid wlan0 | grep 'essid:' | cut -c 18-24 | sed -e 's/^"//' -e 's/"$//') [[ -z "$wtf" ]] && echo -e "wi-fi not connected!" || echo -e "connected" [[ ! -z "$wtf" ]] && echo -e "connected" || echo -e "wi-fi not connected!"
...that said -- awful code. readers, please don't consider places i'm quoting op condoning same. :)
Comments
Post a Comment