I'm having an issue with the xfce4-genmon-plugin. I'm using it to monitor my vpn connection. Whenever I'm connected to my VPN (NordVPN using openpyn), it displays a symbol and the server I'm connected to with this command : $(ps ax | grep $(pidof openvpn) | perl -n -e '//(\w+) .nordvpn.com/ && print $1')
I recently decided I would also like it to display my current IP address (WAN)
I've written a short bash script that regularly checks the IP address with the command $(wget http://checkip.dyndns.org/ -O - -o /dev/null | cut -d: -f 2 | cut -d\< -f 1) This is stored in an environment variable called IPPUBLIQUE and it works fine.
The next step was to write a script for the generic monitor plugin which is here :
#!/bin/bash
echo $IPPUBLIQUE
ip=$IPPUBLIQUE
echo $ip
ip="IP:$ip"
echo $ip
checkvpn=$(nmcli con |grep tun0)
if [ -n "$checkvpn" ]
then
echo "<img>/home/richard/Scripts/vpn.png</img>"
echo "<txt>$ip; "$(ps ax | grep $(pidof openvpn) | perl -n -e '/\/(\w+) \.nordvpn\.com/ && print $1')"</txt>"
echo "<click>/home/richard/bin/./killvpngenmon.sh</click>"
echo "<tool>Connected to VPN</tool>"
echo "<img>/home/richard/Scripts/novpn.png</img>"
else
echo "<img>/home/richard/Scripts/novpn.png</img>"
echo "<txt>$ip</txt>"
echo "<click>gksudo /home/richard/bin/autovpn</click>"
echo "<tool>Not connected to VPN</tool>"
echo "<img>/home/richard/Scripts/vpn.png</img>"
fi
When I test the script in a console, the values of each variable is correct and are printed out with the echo commands. They ll contain the correct IP addresses. However the monitor only displays the $ip as "IP: ". No matter what I do, it refuses to display my IP address, but if I set the variable manually (for example ip=192.168.0.1 instead of ip=$IPPUBLIQUE) then it works.
Can anyone help figure out what is going on and how I can correct it?
Thanks a lot