Hi expert,
I'm newbie in awk programming and now I have difficulty how to make awk array in ash shell. I have code below.
As you know ash shell doesn't support array and I cannot install bash
in my embedded environment.
So in order this code to work in ash shell then all array needs to be converted
Problem now while creating array in ash shell :
and calling array in ash shell :
Can somebody help me on this?
I'm newbie in awk programming and now I have difficulty how to make awk array in ash shell. I have code below.
As you know ash shell doesn't support array and I cannot install bash
in my embedded environment.
So in order this code to work in ash shell then all array needs to be converted
Problem now while creating array in ash shell :
Code:
scene[$SCNCNT]=$(echo $line | awk '{ print $2 }')
Code:
echo "MSG~heyu $(echo ${scene[${phone#*~}]})" | tee -a $LOG
$HEYU $(echo ${scene[${phone#*~}]})
Code:
#!/bin/sh
HEYU=/usr/bin/heyu # Path to Heyu
SED=/usr/bin/sed
SORTAZ=0 # If 0, will sort by house code.
get_scenes() {
SCENES=$($HEYU show usersyns | grep "usersyn")
if [ "$SORTAZ" -eq "1" ]
then
SCENES=$(echo "$SCENES" | sort)
fi
IFS=$(echo -en "\n\b")
for line in $SCENES
do
let SCNCNT=$SCNCNT+1
scene[$SCNCNT]=$(echo $line | awk '{ print $2 }')
echo -n "S: " >> $LOG
echo $line | awk '{ print "SCENE~" $2 "~'$SCNCNT'" }' | sed 's/_/ /g' | \
sed 's/.*/\L&/; s/[a-z]*/\u&/g' | tee -a $LOG
done
IFS=$ORIGIFS
}
set_scene() {
echo -n "S: " >> $LOG
echo "MSG~heyu $(echo ${scene[${phone#*~}]})" | tee -a $LOG
$HEYU $(echo ${scene[${phone#*~}]})
sleep 1
get_updates "$DEVICES"
}
get_scenes
set_scene