Sponsored Content
Top Forums Shell Programming and Scripting Set variables from file, then loop Post 302542797 by Nitrodist on Thursday 28th of July 2011 03:43:18 PM
Old 07-28-2011
What does set${ID} do?

What you need to do is build up a file with the appropriate commands and then feed that to bteq afterwards.

Code:
CMD_FILE=/tmp/a

echo ".logon $LOGON_STRING_DEV;" > $CMD_FILE
cat ${FILE} | sed 's/,/ /g' | tr ' ' '\n' | while read ID
do

cat <<EOF >> $CMD_FILE
CREATE USER ${ID} FROM PROD_JOB_USERS  AS
       PERM=0,                            
       PASSWORD = ********             
       ACCOUNT='********'            
       DEFAULT DATABASE=PROD_DB;       
GRANT  DROP DATABASE ON ${ID} TO ALL PROD_DBA;                        
GRANT  DROP USER ON ${ID} TO ALL PROD_DBA;                        
GRANT  ALL ON ${ID} TO DBC WITH GRANT OPTION;
GRANT BATCH_JOB_ROLE TO ${ID};
MODIFY USER ${ID} AS DEFAULT ROLE = ALL;             
EOF

done

echo ".quit" >> $CMD_FILE

cat $CMD_FILE | bteq


Something like this. Notice how you need lines in order for the whileloop to work as you imagine, so I made each entry a new line instead of it being on the same line.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using Variables to Set Other Variables

I have a script that I'm trying to shorten (below) by removing repetitive code. if ] then commodity_ndm_done=Y fi if ] then customer_ndm_done=Y fi if ] then department_ndm_done=Y fi if ] then division_ndm_done=Y fi (3 Replies)
Discussion started by: superdelic
3 Replies

2. Shell Programming and Scripting

Ksh script - Design ? - Search file and set variables

Hi - I'm trying to think of a clever way to write a shell script (trying to stay w/ ksh as that's what I know the best...) that will resolve the following problem: Problem - On a daily basis I have to email folks who are on-call to remind them. I was hoping to script this out so I could have... (9 Replies)
Discussion started by: littlefrog
9 Replies

3. Shell Programming and Scripting

Is there a better way I could have run this loop. (For loop with two variables)

Sorry for such a dreadful title, but I'm not sure how to be more descriptive. I'm hoping some of the more gurutastic out there can take a look at a solution I came up with to a problem, and advice if there are better ways to have gone about it. To make a long story short around 20K pieces of... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

4. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

5. Shell Programming and Scripting

how to create variables in loop and assign filename after set command?

Hi, does anybody knows how to manage, that the filenames are assigned to a variable in a loop afer getting them with set command in a ksh, like: set B*.txt i=1 c=$# x=$((c+1)) echo "$x" while ] ; do _ftpfile$i="$"$i echo "$_ftpfile$i" i=$((i+1)) done The first echo returns,... (2 Replies)
Discussion started by: spidermike
2 Replies

6. Shell Programming and Scripting

For loop using input file doesn't expand variables

Hi, I'm using a for loop reading from an input file that contains files, whose path includes a variable name. But the for loop doesn't expand the variable and therefore can't find the file. Here's an example: File BACKUPFILES /home/John/alpha /home/Sue/beta... (8 Replies)
Discussion started by: Hesiod
8 Replies

7. Shell Programming and Scripting

Need to SET Environment variables

Hi Could you please tell me how to set environment variables in Unix ksh. And how can acess those varibles in shell scripts ( Please give the code with an example) For my scenario. We have written number of shell scripts with hard coded username and password. But if we want to... (1 Reply)
Discussion started by: shyamu544
1 Replies

8. Shell Programming and Scripting

How to set a variable name from another variables value?

Experts, I want to set value of variables like this in bash shell: i=5 ; L=100 I want variable d5 (that is d(i) ) to be assign the value of $L , d$i=$L ; echo $d5 Not working Thanks., (3 Replies)
Discussion started by: rveri
3 Replies

9. Programming

[LUA] Set variables according to if file exists

Heya I'm using Awesome WM with the Vicious widget library. As i'm using multi boot, Win8, Fedora and Arch, i have my WM-Config shared accross my GNU/Linux installations. The regarding snippet: -- Functions -- Its just a workaround for an 'unstable' 'hwmon/hwmon' definition of Fedora21 -... (0 Replies)
Discussion started by: sea
0 Replies

10. Shell Programming and Scripting

HELP - loop a curl command with different variables from input file

Hi guys! Kind of new to bash scripting and now I'm stuck. I need to curl with these variables: "{ \"nodename\": \"$1\", \"ipaddress\": \"$2\", \"poolname\": \"$3\", \"port\": \"$4\", \"loadbalancer\" : \"$5\" }" and my input_file.txt contains server001 10.10.10.01 serverpool1 80... (4 Replies)
Discussion started by: yort
4 Replies
ALTER 
GROUP(7) SQL Commands ALTER GROUP(7) NAME
ALTER GROUP - change role name or membership SYNOPSIS
ALTER GROUP groupname ADD USER username [, ... ] ALTER GROUP groupname DROP USER username [, ... ] ALTER GROUP groupname RENAME TO newname DESCRIPTION
ALTER GROUP changes the attributes of a user group. This is an obsolete command, though still accepted for backwards compatibility, because groups (and users too) have been superseded by the more general concept of roles. The first two variants add users to a group or remove them from a group. (Any role can play the part of either a ``user'' or a ``group'' for this purpose.) These variants are effectively equivalent to granting or revoking membership in the role named as the ``group''; so the preferred way to do this is to use GRANT [grant(7)] or REVOKE [revoke(7)]. The third variant changes the name of the group. This is exactly equivalent to renaming the role with ALTER ROLE [alter_role(7)]. PARAMETERS
groupname The name of the group (role) to modify. username Users (roles) that are to be added to or removed from the group. The users must already exist; ALTER GROUP does not create or drop users. newname The new name of the group. EXAMPLES
Add users to a group: ALTER GROUP staff ADD USER karl, john; Remove a user from a group: ALTER GROUP workers DROP USER beth; COMPATIBILITY
There is no ALTER GROUP statement in the SQL standard. SEE ALSO
GRANT [grant(7)], REVOKE [revoke(7)], ALTER ROLE [alter_role(7)] SQL - Language Statements 2010-05-14 ALTER GROUP(7)
All times are GMT -4. The time now is 09:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy