Why does this script mark that the service has not been found? [closed]

1

This is the script that I am using and the only thing that marks is [o: not found

#!/bin/bash
control=0
while [ $control != "1" ]; do
 clear
 service='ps awx | grep 'isc-dhcp-server'|grep -v grep |wc -l'
 if [$service==0];then
   estado="OFF"
  else
   estado="ON"
  fi
 echo -e "PANEL DE CONTROL \n"
 echo -e "Estado ----->> $estado \n\n"
 echo "1. ON server"
 echo "2. OFF server"
 echo -e "3. Salir \n"
 case $opcion in
 1)
 service isc-dhcp-server start
  sleep 5 ;;
 2)
 service isc-dhcp-server stop
  sleep 5 ;;
 3)
  echo -e "\n"
  control=1 ;;
 esac
done
exit
    
asked by Rafa 23.04.2018 в 21:54
source

1 answer

0

The script had some errors in the while the solution I found was the following

#!/bin/bash

apa='apache2'
my='mysql'
dh='isc-dhcp-server'
servis=ps ax | grep -v grep | grep $apa
if [$servis>/dev/null]; then
    estado="OFF"
else
    estado="ON"
fi
serv=ps ax | grep -v grep | grep $my
if [$servis>/dev/null]; then
    estados="OFF"
else
    estados="ON"
fi
ser=ps ax | grep -v grep | grep $dh
if [$servis>/dev/null]; then
    e="OFF"
else
    e="ON"
fi
while :
do
clear
echo "Panel de control de Apache"
echo "Estado--->$estado"
echo "Panel de control de MySQL"
echo "Estado--->$estados"
echo "Panel de control de DHCP"
echo "Estado--->$e"
echo "1. ON Apache"
echo "2. OFF Apache"
echo "3. ON MySQL"
echo "4. OFF MySQL"
echo "5. ON DHCP"
echo "6. OFF DHCP"
echo "7. Activar todos"
echo "8. Salir"
read -p "Ingresa la Opcion..." opcion
case $opcion in
1)
/etc/init.d/apache2 start
estado="ON"
echo "ACTIVADO"
sleep 2;;
2)
/etc/init.d/apache2 stop
estado="OFF"
echo "APAGADO"
sleep 2;;
3)
/etc/init.d/mysql start
estado="ON"
echo "ACTIVADO"
sleep 2;;
4)
/etc/init.d/mysql stop
estado="OFF"
echo "APAGADO"
sleep 2;;
5)
/etc/init.d/isc-dhcp-server start
estado="ON"
echo "ACTIVADO"
sleep 2;;
6)
/etc/init.d/isc-dhcp-server stop
estado="OFF"
echo "APAGADO"
sleep 2;;
7)
/etc/init.d/apache2 start
/etc/init.d/mysql start
/etc/init.d/isc-dhcp-server start
estado="ON"
estados="ON"
e="ON"
echo "ACTIVADOS"
sleep 2;;
8)
exit;;
esac
done 
    
answered by 25.04.2018 в 01:19