As grail asked, please use [code][/code]
tags around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, colors, or other fancy formatting.
Note again, code
tags, NOT quote tags.
Of course that assumes that you are using good formatting in the first place. Clean, consistent formatting makes code readable and more easily debuggable. Indent all your sub-commands, and separate logical sections with whitespace. Add comments anywhere the code isn't completely obvious (and remember, what seems obvious to you now will not be a year or so down the line).
Many people also think that it's more readable to place the "do/then
" keywords on the same line as the "for/while/until/if
" keywords, as it more clearly separates the outside block from the inside block.
for var in fee fai foo fum ; do
if [[ "$var" == "foo" ]]; then
echo "Found 'foo'."
Environment variables are generally all upper-case. So while not absolutely necessary, it's good practice to keep your own user variables in lower-case or mixed-case, to help differentiate them.
Finally, when using bash
, it's recommended to use ((..))
for numerical tests, and [[..]]
for string tests and other complex expressions. Avoid using the old [..]
test unless you specifically need POSIX-style portability.
Concerning the script itself, it generally looks ok to me. The only funny thing that I see offhand is that you set a "DIR" variable that you never use anywhere.
It's also not advisable to store the username and password directly in the script. It would be better to either pass them to it from the command line, or store them in a separate file and source or read that into the script.