我正在尝试使用我的覆盆子pi上的open vpn创建一个 VPN ,我正在使用终端键入一个文件,为我想要连接的设备创建一个配置文件脚本。使用 BBC 的分步指南。我一直试图解决这个问题大约一个小时,我一直得到同样的错误请帮助。
#!/bin/bash
DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
echo "Please enter an existing Client Name:"
read NAME
if [!-f$NAME$CRT]; then
echo "[ERROR]: Client Public Key Certificate not found: $NAME$CRT"
exit
fi
echo "Client's cert found:$NAME$CR"
if [!-f$NAME$KEY]; then
echo "[ERROR]: Client 3des Private Key not found:$NAME$KEY"
exit
fi
echo "Client's Private Key found:$NAME$KEY"
答案 0 :(得分:3)
尝试在if语句中添加其他空格:
if [ ! -f $NAME$CRT ]; then
完整的脚本现在是:
#!/bin/bash
DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
echo "Please enter an existing Client Name:"
read NAME
if [ ! -f $NAME$CRT ]; then
echo "[ERROR]: Client Public Key Certificate not found: $NAME$CRT"
exit
fi
echo "Client's cert found:$NAME$CR"
这是一个显示它有效的演示:
$ chmod +x ./myscript
$ touch foo.crt
$ ./myscript
Please enter an existing Client Name:
foo
Client's cert found:foo
$ ./myscript
Please enter an existing Client Name:
bar
[ERROR]: Client Public Key Certificate not found: bar.crt
答案 1 :(得分:-2)
Try this
#!/bin/bash
`DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
echo "Please enter an existing Client Name:"
read NAME
if[ !-f $NAME$CRT ]; then
echo "[ERROR]: Client Public Key Certificate not found: $NAME$CRT"
exit
fi
echo "Client's cert found:$NAME$CR"
答案 2 :(得分:-2)
我所做的就是在if
之后添加一个空格,它超出了你的错误。
#!/bin/bash
DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
echo "Please enter an existing Client Name:"
read NAME
if [ ! -f $NAME$CRT ]; then
echo "[ERROR]: Client Public Key Certificate not found: $NAME$CRT"
exit
fi
echo "Client's cert found:$NAME$CR"