I am learning to use zenity with some simple bash scripts I wrote. I need to compare the command output of a list selection with a string. Everything I find uses variables. I am NOT using a variable I am using the direct output of the zenity list selection and need to compare it to a string for an if-else statement.
This is the example of what I am trying. I have tried many things and seem to be stuck. I don't need a to hear obnoxious statements of how stupid the script is. The script doesn't matter, I am using a simple script to learn more how to use zenity.
zenity --list --width 390 --height 450 \
--column "Option" \
--column "Action" \
--column "Service" \
FSTAT "FTP Server Status" "Pure FTP Server" \
FRSTRT "Start FTP Server" "Pure FTP Server" \
FFRLD "Force Reload FTP Server" "Pure FTP Server" \
FSTP "Stop FTP Server" "Pure FTP Server" \
SSTAT "SSH Server Status" "SSHD Server" \
SSTRT "SSH Server Start" "SSHD Server" \
SSTP "Stop SSH Server" "SSHD Server" \
ASTAT "Apache Server Status" Apache2 \
ASTRT "Start Apache Server" Apache2 \
ASTP "Stop Apache Server" Apache2 \
C80 "Check Port 80" Servers \
KPROC "Kill Process" "PID Service"
if [[ $? = "FSTAT" ]]; then
echo "Pure FTP Server Status"
echo "Press q to quit"
service pure-ftpd status
elif [[ $? = "FRSTRT" ]]; then
echo "Restart Pure FTP Server"
service pure-ftpd restart
elif [[ $? = "FFRLD" ]]; then
echo "Force-Reload Pure FTP Server"
service pure-ftpd force-reload
elif [[ $? = "FSTP" ]]; then
echo "Stop Pure FTP Server"
service pure-ftpd stop
elif [[ $? = "SSTAT" ]]; then
echo "Press q to quit"
echo "SSHD Server Status"
service sshd status
elif [[ $? = "SSTRT" ]]; then
echo "Start SSHD Server"
service sshd start
elif [[ $? = "SSTP" ]]; then
service sshd stop
echo "Stop SSHD Server"
elif [[ $? = "ASTAT" ]]; then
echo "Press q to quit"
echo "Apache2 Server Status"
service apache2 status
elif [[ $? = "ASTRT" ]]; then
echo "Start Apache2 Server"
service apache2 start
elif [[ $? = "ASTP" ]]; then
echo "Stop Apache2 Server"
service apache2 stop
elif [[ $? = "C80" ]]; then
echo "Check Port 80"
sudo netstat -tulpn | grep :80
elif [[ $? = "KPROC" ]]; then
# ADD ZENITY STATEMENT HERE
echo "Kill Process"m
else
exit 0
fi