Help fix my script. syntax error: unexpected end of file
This is probably simple and i probably am not doing this in the most elegant fashion, so any help would be appreciated. When i run the script it works fine but at the end i receive the follow message
"line 16: syntax error: unexpected end of file" Here is my script Quote:
|
use code instead of quote for code.
anyway.. see bold comment Code:
#!/usr/bin/env bash -x |
you might be better using select/ case instead of read/ case
|
Think through what you are intending as the logical flow of the case statements you are starting on lines 8 and 11. Indenting your code may help. One of those case statements is never closed. The shell expects more but hits the end of the file.
|
Quote:
|
Quote:
|
Think i fixed it. I had to close the case after esac on line 17
Code:
#!/usr/bin/env bash -x |
One of the more useful concepts in scripting is keeping your data separate from your code as much as possible.
One of the primary ways to do this is to pre-define all of your file paths and other fixed data strings in variables at the top of the script, rather than embedding them in the script. It keeps the clutter down and makes things cleaner and easier to debug, as well as making them easier to alter without having to go through the whole script. Specifically, the following three strings of yours should all be pre-configured as variables: mnadmin@contoso.com /home/mnadmin/ops/tenant_admin/tenantcfg.rb https://contoso.com In addition, since the same ssh command appears over and over with only minor variations, that makes it a perfect candidate for a function. preconfigure the basic command at the top of the script, and call it with the proper options when the need arises. Check out Scripting With Style for more tips on how to write clean and robust code. |
All times are GMT -5. The time now is 06:41 PM. |