Dear Forum, I have a question in regards to scripting. I want to check if the firewall on my system is enabled.
This terminal command:
returns following:
That is all fine and correct! However if I use this script:
It will always return:
no matter if it is running or not.
I think the problem lies in the argument. I tried this:
and this:
and a couple of other variations but same result: "Firewall is DISABLED"
How needs the argument look like to check if a service is running on my computer?
Thanks,
Uwe
This terminal command:
Code:
/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
returns following:
Code:
Firewall is enabled. (State = 1)
That is all fine and correct! However if I use this script:
Code:
#!/bin/zsh
# check if Firewall is enabled
if ( "/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate" ) ; then
echo "Firewall is Enabled"
else
echo "Firewall is DISABLED"
fi
exit
It will always return:
Code:
Firewall is DISABLED
I think the problem lies in the argument. I tried this:
Code:
if ( "/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate" = 1 ) ; then
and this:
Code:
if ( "/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate" = “Firewall is enabled. (State = 1)“ ) ; then
and a couple of other variations but same result: "Firewall is DISABLED"
How needs the argument look like to check if a service is running on my computer?
Thanks,
Uwe