facing error as syntax error near unexpected token fi' [closed]












0















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









share|improve this question









New contributor




user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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 expect else to be unexpected here.

    – Stéphane Chazelas
    Jan 15 at 13:57
















0















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









share|improve this question









New contributor




user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











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 expect else to be unexpected here.

    – Stéphane Chazelas
    Jan 15 at 13:57














0












0








0








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









share|improve this question









New contributor




user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question









New contributor




user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Jan 15 at 12:38









Kusalananda

125k16236389




125k16236389






New contributor




user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Jan 15 at 12:24









user331577user331577

1




1




New contributor




user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user331577 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




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 expect else to be unexpected here.

    – Stéphane Chazelas
    Jan 15 at 13:57














  • 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








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










1 Answer
1






active

oldest

votes


















1














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





share|improve this answer



















  • 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




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














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





share|improve this answer



















  • 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


















1














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





share|improve this answer



















  • 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
















1












1








1







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





share|improve this answer













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






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 15 at 13:53









wurtelwurtel

10.3k11426




10.3k11426








  • 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
















  • 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










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





Popular posts from this blog

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

19世紀