![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk/sed/ksh script to cleanup /etc/group file | pdtak | Shell Programming and Scripting | 6 | 02-28-2008 03:33 AM |
| File Owner/Group through Shell Script | rahulrathod | Shell Programming and Scripting | 1 | 02-26-2008 02:45 PM |
| Spice up Joomla! with productivity-enhancing extensions | iBot | UNIX and Linux RSS News | 0 | 12-24-2007 06:00 AM |
| Monkcast #12: IBM HW group OEMs Solaris to chagrin of SW group & a ... - ZDNet.com bl | iBot | UNIX and Linux RSS News | 0 | 08-17-2007 05:30 PM |
| entry in /etc/group too long - problem using sudo with %group | poli | SUN Solaris | 4 | 12-21-2004 09:50 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Enhancing Script (using loops) to go through for each group
Currently I have written a shell script that will add departments for one group (displayed below with configuration file). I want to enhance the script in order to add departments to multiple groups by:
1. Making changes to allow the script to loop through and write each dept/group combo into the DEPTFILE. 2. After I get the dept list from the config file, check to see if the Group flag is on and if it is, then create a loop to go through for each group. In the original configuration file, only one country was passed in (Brazil). Since then, I changed the variable to ${Cntry_code} (instead of just Brazil) and I added US in the config file. Please let me know if anymore information is needed Thanks in advance Here is the script that I have currently: bin/ksh ############################################################################ # Program: add_BING_group.sh # Desc : this manually executed script will allow you to add a group # and/or depts in BING # Notes : To run this script pass in the country code. # add_BING_group.sh <country_code> # It uses addGroup.cfg to get the correct information to add # Be sure that you make the correct changes in the cfg file before # running the script # ################################################################# ## checking a script call for the proper number of arguments if [ "$#" -ne 1 ] then echo "USAGE: $0 <country_code>" exit 0 fi Cntry_code=$1 GROUP=`stanzaget addGroup.cfg ${Cntry_code} group` BINGDB=`stanzaget addGroup.cfg ${Cntry_code} database` GROUPFLAG=`stanzaget addGroup.cfg ${Cntry_code} addGroupFlag` DEPTFLAG=`stanzaget addGroup.cfg ${Cntry_code} addDeptFlag` dept_groupSQL="/tmp/dept_group.sql" text_SQL="/tmp/groupText.sql" DEPTFILE="/tmp/deptfile.unl" DEPT_GRP_UNL="/tmp/dept_back.unl" PATH=$PATH:$ITOOLSDIR/bin `rm ${DEPTFILE}` if [ ${GROUPFLAG} = "ON" ] then PLANG_CODE=`stanzaget addGroup.cfg ${Cntry_code} pri_lang_code` PGRP_TXT=`stanzaget addGroup.cfg ${Cntry_code} pri_text` SLANG_CODE=`stanzaget addGroup.cfg ${Cntry_code} sec_lang_code` SGRP_TXT=`stanzaget addGroup.cfg ${Cntry_code} sec_text` echo " Begin work; " > ${dept_groupSQL} echo " insert into ${BINGDB}:dept_group values(${GROUP}); " >> ${dept_groupSQL} echo " commit work; " >> ${dept_groupSQL} echo " Begin work; " > ${text_SQL} echo " insert into ${BINGDB}:dept_group_text values(${GROUP},${PLANG_CODE},'${PGRP_TXT}'); " >> ${text_SQL} echo " insert into ${BINGDB}:dept_group_text values(${GROUP},${SLANG_CODE},'${SGRP_TXT}'); " >> ${text_SQL} echo " insert into ${BINGDB}:dept_group_text values(10,103,'${TGRP_TXT}'); " >> ${text_SQL} echo " commit work; " >> ${text_SQL} dbaccess ${BINGDB} < ${dept_groupSQL} echo "Loaded the group table" dbaccess ${BINGDB} < ${text_SQL} echo "Loaded the text table" fi if [ ${DEPTFLAG} = "ON" ] then DEPTLIST=`stanzaget addGroup.cfg ${Cntry_code} dept_list` `iunload -d ${BINGDB} -t dept_dept_group -compress -isolation dirty ${DEPT_GRP_UNL}` if [ ${DEPTLIST} = "ALL" ] then DEPTLIST=`stanzaget addGroup.cfg ${Cntry_code} dept_list_all` for d in `echo $DEPTLIST | sed 's/,/ /g'` do echo "$d|${GROUP}|" >> ${DEPTFILE} done fi `iload -d ${BINGDB} -t dept_dept_group ${DEPTFILE}` Fi %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Configuration File (addGroup.cfg) US: database = bingusa group=0,1,2,3,4,5,6,7,8,9,10 group_text = #addGroupFlag = OFF addGroupFlag = ON addDeptFlag = ON dept_list=ALL dept_list_all=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,75,77,80,81,82,8 3,84,85,87,88,90,91,92,93,94,95,96,97,98,99 Brazil: database = bingbrazil group = 11 #group = 10 #addGroupFlag = OFF addGroupFlag = ON addDeptFlag = ON pri_lang_code = 101 pri_text=FALL/WINTER sec_lang_code = 103 sec_text=AUTOMNE/HIVER third_text=Printemps/Été dept_list=ALL dept_list_all=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31, 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,75,77,80,81,82,8 3,84,85,87,88,90,91,92,93,94,95,96,97,98,99 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|