Wednesday, June 28, 2006
12:36 AM

Single Writer Multiple Readers using Anonymous Pipes

Use the tee command. Here is an example where I use pipes and the linux cut/paste command to implement a windows like "scanning wireless networks available" in linux.



scan_nets(){
echo "Going to scan nets"
rm -rf *.trace
iwlist $wintf scanning | tee >(grep "ESSID" |cut -d ':' -f 2 > essid.trace ) >(grep "Encryption"|cut -d ':' -f 2 > enc.trace ) | (grep "Quality"|cut -d '=' -f 2 > quality.trace)

paste -d " :" essid.trace enc.trace <(cut -d " " -f 1,3 quality.trace) > table
availnets=`cat table`

selected_net=$($DIALOG --stdout --title "Scanned Networks Available. " --radiolist "Press Cancel to enter your own ESSID

ESSID Encypted? Signal Strength" 18 45 12 $availnets)
retval1=$?
case $retval1 in
0)
echo "Input string is $selected_net";;
1)
echo "Cancel pressed.";;
#No problem will prompt for essid later
255)
$DIALOG --no-close --no-buttons --title "Disable Network" --infobox "User Interrupt going to disable the network" 8 32 10
;;
esac
}

0 comments:

Post a Comment