You are not logged in.
Pages: 1
I'm trying to write a zsh script for dzen, and I'm not sure to change a global variable from within a function. With the following function it seems to be creating a local RXB and TXB instead of updating the global ones:
fnet() {
RXBN=`cat /sys/class/net/${NET_DEVICE}/statistics/rx_bytes`
TXBN=`cat /sys/class/net/${NET_DEVICE}/statistics/tx_bytes`
RXR=$(((RXBN - RXB) / 1024 / NETIVAL))
TXR=$(((TXBN - TXB) / 1024 / NETIVAL))
TEMP="r0 $RXB r1 $RXBN r $RXR ... t0 $TXB t1 $TXBN t $TXR"
RXB=$((RXBN))
TXB=$((TXBN))
print $TEMP
#print "${NET_DEVICE}: dn ${RXR} kB/s up ${TXR} kB/s"
}
The full script: http://sprunge.us/HJEa?sh
How do I fix this?
Offline
i can't run your script since i don't have those files/folders so i'm somewhat confused, trying to decipher how it should work. you have RXB as the same parameter as RXBN in the function and RXB updating as RXBN? are you getting any errors when you run the script, such as a command not found or does it just show the same parameters that don't update?
Offline
Pages: 1