>On Wednesday, February 21st, 2024 at 1:01 PM, Bo Berglund 
><bo.bergl...@gmail.com> wrote:

> On Wed, 21 Feb 2024 06:59:25 +0000, Peter Davis via Openvpn-users
> openvpn-users@lists.sourceforge.net wrote:
> 
> > > On Tuesday, February 20th, 2024 at 8:26 PM, Bo Berglund 
> > > bo.bergl...@gmail.com wrote:
> > 
> > > On Tue, 20 Feb 2024 11:29:36 +0000, Peter Davis via Openvpn-users
> > > openvpn-users@lists.sourceforge.net wrote:
> > > 
> > > > Hi,
> > > > Thanks again.
> > > > Can you make the report be saved to a file?
> > > 
> > > What do you think this does? :
> > > 
> > > LOG_FILE="/etc/openvpn/log/server-events.log"
> > > echo "$LOG_TIMESTAMP - $common_name connected with IP $trusted_ip" >>
> > > 
> > > "$LOG_FILE"
> > > 
> > > Solution:
> > > 
> > > 1) LOG_FILE is declared as a filename
> > > 2) echo "$LOG_TIMESTAMP - $common_name ..." >> "$LOG_FILE"
> > > 
> > > The second command adds the new info to the end of the defined file
> > > 
> > > What is it you do not understand?
> 
> > Hi,
> > I got the following error:
> > 
> > # sh /etc/openvpn/scripts/script-events.sh
> > /etc/openvpn/scripts/script-events.sh: 6: [: ==: unexpected operator
> > /etc/openvpn/scripts/script-events.sh: 14: [: unexpected operator
> > /etc/openvpn/scripts/script-events.sh: 16: [: unexpected operator
> 
> 
> 
> I don't know why you are using sh, the script shebang says; #!/bin/bash
> so why do you use sh when testing?
> If the system you use does not read the shebang but selects the executable by
> the file extension then you may want to remove the .sh extension and just 
> leave
> the bare name script-events.
> 
> The lines referred to above are:
> 
> 6: if [ ${LOG_FILE} == "" ]; then
> 
> 14: if [ "$script_type" == "client-connect" ]; then
> 
> 16: elif [ "$script_type" == "client-disconnect" ]; then
> 
> It seems like your system does not like single brackets inside scripts...
> 
> You may want to modify these lines to use double brackets like so:
> 
> if [[ "${LOG_FILE}" == "" ]]; then
> 
> if [[ "$script_type" == "client-connect" ]]; then
> 
> elif [[ "$script_type" == "client-disconnect" ]]; then
> 
> 
> On what operating system are you running the openvpn server and hence the
> script?
> My usage is with Ubuntu Server 20.04 and 22.04 LTS.
> 
> 
> --
> Bo Berglund
> Developer in Sweden
> 
> 
> 
> _______________________________________________
> Openvpn-users mailing list
> Openvpn-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-users

Hello,
I use Debian. I used "bash" instead of "sh":

# bash script-events.sh 
script-events.sh: line 6: [: ==: unary operator expected

I changed "[" to "[[":

# bash script-events.sh 
#

Seems OK?


_______________________________________________
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users

Reply via email to