hi, unix wizards,
i have a question about the logic of my inner for loop below. first, what i am trying to do is to write a script called create_account that automatically creates mysql accounts. the user can provide a user_name or a group_id as an argument (and the script can take multiple arguments). user_name arguments should simply be appended to a user_file.
group ids should be compared to a file that contains a list of group_ids with multiple user_names per id. if the group id exists, then grab all the users and append to the user_file. if the group id does not exist, print "group id not valid".
of course, the first thing i have to do is validate the argument -- if its a number of a certain type, i assume its a group_id. else, it's a user_name. btw, "is_num" is a function to validate if the argument is a number (and hence, a group_id).
----------------------------------------------
get arg
- if argument is a number
- if num is invalid group_id,
- then print "group id not valid"
- if num is valid group_id
- then parse group_id_file and grab users from 4th field on
----------------------------------------------
my code works well when i have just one arguement and it doesn't matter if the arguement is valid group_id, an invalid group_id, or a user_name. but when i use multiple parameters, the problems with my code are:
- user_name arguments are getting passed through the inner for loop and shouldn't be because they don't pass the is_num function criteria
- commands with multiple parameters run all arguments multiple times