Script to run command against multiple specific value in one file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to run command against multiple specific value in one file
# 1  
Old 07-21-2011
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.

Code:
#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:
Code:
./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
Code:
-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.

Last edited by Mr_47; 08-14-2011 at 03:42 PM..
# 2  
Old 07-24-2011
help please. currently have no idea to get this done.
# 3  
Old 07-26-2011
too complicated? yup
# 4  
Old 07-26-2011
execute the below code and make sure the command is correct.

once it is correct, remove the comment #

Code:
 
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

# 5  
Old 07-27-2011
thx, still testing it, ill update the result soon
# 6  
Old 08-11-2011
any idea on how to run this command directly from console? without using cronjob?
# 7  
Old 08-11-2011
save the code in a normal file and assign execute permission and execute it
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Python script to run multiple command and append data in output csv file

Experts, I am writing a script and able to write only small piece of code and not able to collect logic to complete this task. In input file have to look for name like like this (BGL_HSR_901_1AG_A_CR9KTR10) before sh iss neors. Record this (BGL_HSR_901_1AG_A_CR9KTR10) in csv file Now have to... (0 Replies)
Discussion started by: as7951
0 Replies

2. Shell Programming and Scripting

Script to run #groups command on list in a file

I have to provide a listing of all usernames and group assignments on Linux servers running SLES 12 SP 3. I am trying to automate this via a #for loop. It is not doing as desired and could use a little assistance. Here is the code: #!/bin/bash for uname in 'cat $(hostname)_unlist.txt' do... (8 Replies)
Discussion started by: Kentlee65
8 Replies

3. Shell Programming and Scripting

Script to read file and run multiple jobs

I have a txt file line1 line2 line3 $!/bin/sh cat /tmp/lus.txt | while read line do esxcli storage vmfs unmap -u $lin -n 4000 done this works but does in one line at a time. how do I do all lines at once simutaeously? Please use CODE tags as required by forum rules! (4 Replies)
Discussion started by: tdubb123
4 Replies

4. Shell Programming and Scripting

Script for telnet and run one command kill it and run another command using while loop

( sleep 3 echo ${LOGIN} sleep 2 echo ${PSWD} sleep 2 while read line do echo "$line" PID=$? sleep 2 kill -9 $PID done < temp sleep 5 echo "exit" ) | telnet ${HOST} while is executing only command and exits. (5 Replies)
Discussion started by: sooda
5 Replies

5. Shell Programming and Scripting

help needed with shell script to append to the end of a specific line in a file on multiple servers

Hi Folks, I was given a task to append three IP's at the end of a specific (and unique) line within a file on multiple servers. I was not able to do that with the help of a script. All I could was: for i in server1 server2 server3 server4 do ssh $i done I know 'sed' could be used to... (5 Replies)
Discussion started by: momin
5 Replies

6. Shell Programming and Scripting

Run .command at specific times

Okay so I've got a command to start my java server up, but I want it to start at say 8:00AM and then stop at 11:00PM. In order to stop it I have to type stop and press enter in the terminal. I've been trying to get this to work and I'm having no luck. Here's my command: #!/bin/bash cd "`dirname... (2 Replies)
Discussion started by: JustChillin1414
2 Replies

7. Shell Programming and Scripting

Shell script to run a python program on multiple entries in a file

Hello I am trying to run a python program using shell script, which takes a single argument from a file. This file has one entry per line : 1aaa 2bbb 3ccc 4ddd 5eee ... ... ... My shell script runs the program, only for the last entry : #!/bin/sh IFS=$'\n' for line in $(cat... (2 Replies)
Discussion started by: ad23
2 Replies

8. Shell Programming and Scripting

Run perl script with multiple file arguments

Hello everyone, I have two types of files in a directory: *.txt *.info I have a perl script that uses these two files as arguments, and produces a result file: perl myScript.pl abc.txt abc.xml How can I run this script (in a "for" loop , looping through both types of files)... (4 Replies)
Discussion started by: ad23
4 Replies

9. UNIX for Dummies Questions & Answers

Run Command in Specific Time ...

Guy's I want to make script to run this command solevel every Saturday at 8:00 clock exactly . Can you please help me and teach me how to do this ... (9 Replies)
Discussion started by: IT Helper
9 Replies

10. UNIX for Dummies Questions & Answers

Command to run multiple commands from a file.

I need a command, which could run mutliple commands from a file. Let's say, I have mv fileA1 fileB1 mv fileA2 fileB2 ..... mv fileA20 fileB20 I put these commands in a file, then I need a command to run the file as a whole so that I don't need to type 20 times... Anyone tell me how to... (8 Replies)
Discussion started by: kaixinsjtu
8 Replies
Login or Register to Ask a Question