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
then validate group_id
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
else
append to user_file
----------------------------------------------
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
for example, if i say...
... i get a list with all the valid users times 2
i wonder if anyone has the time to point me in the right direction. thanks for your help.
This looks like sh/ksh/bash scripting. The question is, what are "arg" and "num"?? is this in a shell function or is this found in the "main" part of the shell script?
Hi,
I have a requirement as follows. Have 3 files. Need to match up the data in each one of them and sum up the data by a field and display it. example given below.
File 1 : Name, Emp id
File 2 : Empid, Subject,
File 3 : Subject, Score, Class
Match Emp id in File 1 and File 2 and then... (7 Replies)
Hi,
Here I am trying to query database and check a value, if the value not matches then I wants to re-query the database.Once the value matches, I want to email the reqidstatus_log.txt file. Database query produces a file reqidstatus_log.txt which contains result.
But the query not working as... (3 Replies)
Hi Friends,
I have to do write a shell file based on one flag.If that flag value is 'N' then process look in $DATA are and the normal process continue.If vaule is 'P' then it check for the files in different location $CONV and move those file in $DATA area and rest of the process... (2 Replies)
i need to log the feedback from the ftp server as i'm performing some deletes.
the only way i know of to do this is with the inline redirect << EOF
... but from there to the closing EOF, it's like i'm at the ftp command prompt, so I don't know how to have ksh script logic in there
I have an... (3 Replies)
Hello,
I've got next problem:
I want to examine at the beginning of a script in an if loop that:
1. Is there 4 parameters given
2. If first state is true then: is there switches -e and -d?
3. At the end, how can i indentify them as variebles regardlees to its order.
I was thinking like... (2 Replies)
I would need to with making while loop logic working in shell program when I am new into the shell programing
1) I would need to try to get the file from the remote side ----need to try 15 mins apart for 4 times and terminate the program if file is not available....
I would need to know how I... (4 Replies)
Hi,
I am trying to write a script which will read inputs form user and process those files, I have issue reading the input parameters in a loop. Following is the script...
I run the script as ./Script.sh 3 table1 table 2 table3
NumberOfTables=$1
let TableCount=1
while
do
... (3 Replies)