简体   繁体   中英

./MakeOVPN.sh: line 12: [!-fDanielIphone.crt]: command not found

I am trying to make a VPN using open vpn on my raspberry pi, and I am currently typing a file using the terminal to create a profile script for the devices I want to connect. Using the step by step guide by BBC . I have been trying to fix this problem for about an hour now and I keep getting the same error please help.

#!/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"

Error From Code

Try to add additional spaces inside your if statement:

if [ ! -f $NAME$CRT ]; then

The complete script is now:

#!/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"

Here's a demonstration showing that it works:

$ 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"

All I did was add a space after the if and it got past your error.

#!/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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM