Script to run command against multiple specific value in one file

Hi all,

I am trying to create a shell script from solaris 10 server to run a command into multiple specific value in one file. The command is related to Oracle/Sun JES2005Q4 directory server.

#this is the command,
#from path /jes/ds/slapd-rldap1
./ns-inactivate.pl -h mldap1 -p 389 -D "cn=Directory Manager" -w admin123 \-I "uid=anyname_in_file,ou=People,o=anydomain.com,o=isp"

example for well execute command:

./ns-inactivate.pl -h mldap1 -p 389 -D "cn=Directory Manager" -w admin123 \-I "uid=ris1,ou=People,o=solarisX.com.ru,o=isp"

#this is the file, however I only need the command to run for every username only, such as:
admin,ris1,ris2,ris3,ris4,str1,str2,str3,str4,tg1,tg2,tg3,tg4,tmnet1,tmnet2,tmnet3,tmnet4

-bash-3.00# more 30days.out
user/admin/INBOX
user/ris1@iris.net/INBOX
user/ris2@iris.net/INBOX
user/ris3@iris.net/INBOX
user/ris4@iris.net/INBOX
user/str1@streamyx.com/INBOX
user/str2@streamyx.com/INBOX
user/str3@streamyx.com/INBOX
user/str4@streamyx.com/INBOX
user/tg1@titangroup.com/INBOX
user/tg2@titangroup.com/INBOX
user/tg3@titangroup.com/INBOX
user/tg4@titangroup.com/INBOX
user/tmnet1/INBOX
user/tmnet2/INBOX
user/tmnet3/INBOX
user/tmnet4/INBOX

-any other idea to simplify the process are accepted as long as the objective is the same.
-the objective to use the shell script is to run the command against all username in one file, take note that we may run the shell script more than once because I got 5 different domains for all the users in the file.

help please. currently have no idea to get this done.

too complicated? yup

execute the below code and make sure the command is correct.

once it is correct, remove the comment #

 
while read line;
do
usrid=`echo $line | awk -F"/" '{print $2}'`
echo "Executing for the $usrid"
echo "Command : ./ns-inactivate.pl -h mldap1 -p 389 -D \"cn=Directory Manager\" -w admin123 \-I \"uid=$usrid,ou=People,o=solarisX.com.ru,o=isp\""
# ./ns-inactivate.pl -h mldap1 -p 389 -D "cn=Directory Manager" -w admin123 \-I "uid=$usrid,ou=People,o=solarisX.com.ru,o=isp"
done < 30days.out

thx, still testing it, ill update the result soon

any idea on how to run this command directly from console? without using cronjob?

save the code in a normal file and assign execute permission and execute it

any guide to do this?

1) create a normal file and put the below contents

 
#!/bin/bash
while read line;
do
usrid=`echo $line | awk -F"/" '{print $2}'`
echo "Executing for the $usrid"
echo "Command : ./ns-inactivate.pl -h mldap1 -p 389 -D \"cn=Directory Manager\" -w admin123 \-I \"uid=$usrid,ou=People,o=solarisX.com.ru,o=isp\""
# ./ns-inactivate.pl -h mldap1 -p 389 -D "cn=Directory Manager" -w admin123 \-I "uid=$usrid,ou=People,o=solarisX.com.ru,o=isp"
done < 30days.out

and save it as myscript.sh

2) execute the below command

 
chmod 777 myscript.sh

3) make sure you have the 30days.out file is present in the same directory.

4) execute the script

 
./myscript.sh

5) check the output and make sure is that the same command you want to execute.

6) after the confirmation, remove the # from the 7th line and execute it once again

Hi,

How the same script can be apply to file that contain data like this,

more test3.out

12
2423love
2test10
2test11
2test13
2test15
5281kjs
5494jen
855hg1
936mlk
A1624
A212121
A705236
AAITCM
ACERLITE

and this one

more test4.out

   1 -ujmr@x.com
   1 06537my@x.com
   1 123ahfai@x.com
   1 1capitol@styx.com
   1 1mercury@a.com
   1 31337@yx.com
   1 324css@seax.com
   1 3dotcomp@stre.com
   1 46sdsl@hx.com
   1 4si@x.com
   1 5503@myx.com
   1 6_sense@styx.com

nevermind the questions i already have an idea how to create new script base on that files.

this script will run ns-inactivate.pl with userid including the domain,

-bash-3.00# ./tmnetscript.sh
Executing for the tmnet00003@solarisX.com.ru
Command : ./ns-inactivate.pl -h mldap1 -p 389 -D "cn=Directory Manager" -w admin123 \-I "uid=tmnet00003@solarisX.com.ru,ou=People,o=solarisX.com.ru,o=isp"

how can I change the script so that it will run against userid only,
e.g

-bash-3.00# ./tmnetscript.sh
Executing for the tmnet00003@solarisX.com.ru
Command : ./ns-inactivate.pl -h mldap1 -p 389 -D "cn=Directory Manager" -w admin123 \-I "uid=tmnet00003,ou=People,o=solarisX.com.ru,o=isp"

nevermind, found it myself. thx