I'd like to use variable as condition in case statement. Something similar to:
#!/bin/sh ALLOWED_SERVICES=tomcat6|james; case $1 in $ALLOWED_SERVICES ) service $1 restart ;; * ) echo "Unsupported argument" ;; esac
This doesn't work. When script is started with tomcat6 argument for exapmle, it outpoots "Unsuported argument" message. But when case condition is hardcoded it works ok:
case $1 in tomcat6|james ) service $1 restart ;; * ) echo "Unsupported argument" ;; esac
Is it possible to use variables in this case?