./MakeOVPN.sh:第 12 行:[!-fDanielIphone.crt]:找不到命令
./MakeOVPN.sh: line 12: [!-fDanielIphone.crt]: command not found
我正在尝试在我的 raspberry pi 上使用开放式 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"
尝试在您的 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
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"
我所做的只是在 if
之后添加一个 space 并且它已经超越了你的错误。
#!/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"
我正在尝试在我的 raspberry pi 上使用开放式 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"
尝试在您的 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
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"
我所做的只是在 if
之后添加一个 space 并且它已经超越了你的错误。
#!/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"