facing error as syntax error near unexpected token fi' [closed]
#/bin/sh
file="C:/khushal/prop.txt"
if [ -f "$file" ]
then
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
else
echo "$file not found."
fi
shell-script
New contributor
closed as off-topic by Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar Jan 16 at 10:24
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
#/bin/sh
file="C:/khushal/prop.txt"
if [ -f "$file" ]
then
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
else
echo "$file not found."
fi
shell-script
New contributor
closed as off-topic by Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar Jan 16 at 10:24
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.
5
Put it through shellcheck.net
– Kusalananda
Jan 15 at 12:40
2
I'd expectelse
to be unexpected here.
– Stéphane Chazelas
Jan 15 at 13:57
add a comment |
#/bin/sh
file="C:/khushal/prop.txt"
if [ -f "$file" ]
then
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
else
echo "$file not found."
fi
shell-script
New contributor
#/bin/sh
file="C:/khushal/prop.txt"
if [ -f "$file" ]
then
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
else
echo "$file not found."
fi
shell-script
shell-script
New contributor
New contributor
edited Jan 15 at 12:38
Kusalananda
125k16236389
125k16236389
New contributor
asked Jan 15 at 12:24
user331577user331577
1
1
New contributor
New contributor
closed as off-topic by Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar Jan 16 at 10:24
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.
closed as off-topic by Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar Jan 16 at 10:24
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Kusalananda, Stephen Harris, peterh, Mr Shunz, Archemar
If this question can be reworded to fit the rules in the help center, please edit the question.
5
Put it through shellcheck.net
– Kusalananda
Jan 15 at 12:40
2
I'd expectelse
to be unexpected here.
– Stéphane Chazelas
Jan 15 at 13:57
add a comment |
5
Put it through shellcheck.net
– Kusalananda
Jan 15 at 12:40
2
I'd expectelse
to be unexpected here.
– Stéphane Chazelas
Jan 15 at 13:57
5
5
Put it through shellcheck.net
– Kusalananda
Jan 15 at 12:40
Put it through shellcheck.net
– Kusalananda
Jan 15 at 12:40
2
2
I'd expect
else
to be unexpected here.– Stéphane Chazelas
Jan 15 at 13:57
I'd expect
else
to be unexpected here.– Stéphane Chazelas
Jan 15 at 13:57
add a comment |
1 Answer
1
active
oldest
votes
You don't have a done
token to match the while ... do
statement.
it's often better to short-circuit the script by reversing the test on the file, which results in the if .. then .. else not spanning so many lines. I.e.:
#/bin/sh
file="C:/khushal/prop.txt"
if ! [ -f "$file" ]
then
echo "$file not found."
exit 1
fi
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
done
1
key
andvalue
are being used unsanitized here. Also, useprintf
to output variable data, and double quote expansions.
– Kusalananda
Jan 15 at 16:16
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You don't have a done
token to match the while ... do
statement.
it's often better to short-circuit the script by reversing the test on the file, which results in the if .. then .. else not spanning so many lines. I.e.:
#/bin/sh
file="C:/khushal/prop.txt"
if ! [ -f "$file" ]
then
echo "$file not found."
exit 1
fi
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
done
1
key
andvalue
are being used unsanitized here. Also, useprintf
to output variable data, and double quote expansions.
– Kusalananda
Jan 15 at 16:16
add a comment |
You don't have a done
token to match the while ... do
statement.
it's often better to short-circuit the script by reversing the test on the file, which results in the if .. then .. else not spanning so many lines. I.e.:
#/bin/sh
file="C:/khushal/prop.txt"
if ! [ -f "$file" ]
then
echo "$file not found."
exit 1
fi
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
done
1
key
andvalue
are being used unsanitized here. Also, useprintf
to output variable data, and double quote expansions.
– Kusalananda
Jan 15 at 16:16
add a comment |
You don't have a done
token to match the while ... do
statement.
it's often better to short-circuit the script by reversing the test on the file, which results in the if .. then .. else not spanning so many lines. I.e.:
#/bin/sh
file="C:/khushal/prop.txt"
if ! [ -f "$file" ]
then
echo "$file not found."
exit 1
fi
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
done
You don't have a done
token to match the while ... do
statement.
it's often better to short-circuit the script by reversing the test on the file, which results in the if .. then .. else not spanning so many lines. I.e.:
#/bin/sh
file="C:/khushal/prop.txt"
if ! [ -f "$file" ]
then
echo "$file not found."
exit 1
fi
echo "$file found."
while IFS= read -r key value
do
key=$(echo $key | tr '.' '_')
eval ${key}=${value}
echo "User Id = " ${db_uat_user}
echo "user password = " ${db_uat_passwd}
done
answered Jan 15 at 13:53
wurtelwurtel
10.3k11426
10.3k11426
1
key
andvalue
are being used unsanitized here. Also, useprintf
to output variable data, and double quote expansions.
– Kusalananda
Jan 15 at 16:16
add a comment |
1
key
andvalue
are being used unsanitized here. Also, useprintf
to output variable data, and double quote expansions.
– Kusalananda
Jan 15 at 16:16
1
1
key
and value
are being used unsanitized here. Also, use printf
to output variable data, and double quote expansions.– Kusalananda
Jan 15 at 16:16
key
and value
are being used unsanitized here. Also, use printf
to output variable data, and double quote expansions.– Kusalananda
Jan 15 at 16:16
add a comment |
5
Put it through shellcheck.net
– Kusalananda
Jan 15 at 12:40
2
I'd expect
else
to be unexpected here.– Stéphane Chazelas
Jan 15 at 13:57