Quote:
Of course it is possible to solve the problem in many ways, but I still don't see a way to dinamically create the entries of a case command.
This is correct, i'll give you that. Sorry for misreading your post before, but i was under the impression that you mean it is not possible to
solve the problem while you obviously meant it is not possible to
create case-statements dynamically.
Regarding bash not being well suited for scripting.
Quote:
My shells knowledge is so little that I can't discuss this topic.
But I'm a bit.. confused.
Sorry again, what i said was just an off-topic remark. The reasons for this personal opinion of mine are many but it is quite off-topic here to discuss it. If you are interested I'll send you some pointers per PM, we even have some threads here aobut the shortcomings of bash compared to ksh.
Quote:
What was so wrong with my script?
Nothing at all. If you compare my script and yours closely the logic is similar. The difference is i commented it heavily (the threads O/P comes across as not so experienced in shell scripting and probably will need that to understand the flow of the program), i explained how he could implement the input checks, which come with the "case..esac" and which are missing in your script and i used the shell i suppose he already uses (ksh) because of - as stated - i suppose he works on an AIX system. The reason for this is he uses DB/2 as a database, which is from IBM. AIX is IBMs Unix derivate and it is conceivable that a company buying the database from one vendor will buy the hardware and the OS from the same vendor.
Quote:
And, of course, also in bash you can use an array as you've done in ksh (moreover, it had been my first think: but then select came to my mind, and it does the work, and it's much quicker. So why not use it, if bash is available?).
"select" as well as arrays are available in ksh and bash alike - even with an identical syntax. I decided against it in my solution because i wanted better control over the output ("select" always goes to <stderr> for instance) and the program flow. It is just usually better to stick to the default shell on any system. For the same reasons i advocate the ksh here on a - probable- AIX system i would advocate using the bash on, say, a GNU/Linux system, even if i still think ksh is the better shell, but that is just personal conviction. ksh is the default shell here, bash is the one there and hence they should be used accordingly if at all possible.
Quote:
LOL!
Of course you're speaking to the OP.
AIX... I'm not a sysadmin, nor my job is heavily computer related. So, AIX... (AKA "blood and tears", as someone says): I - personally - have never seen an AIX system.
Yes, that was addressing the OP. AIX evolved from being "the best MVS IBM ever created" (this was the saying back in the days of AIX 3.2.3, when i started working with it - ~1993) to one of the most widely spread and most standard-adhering Unixes at all (5L and above). If you buy hardware from IBM (the POWER6 and POWER5 processors were by far the fastest processors of their times, so many companies did exactly that) you will have to use either Linux or AIX and most companies used AIX in this case.
I hope we have sorted out the misunderstandings.
bakunin