Sponsored Content
Top Forums Shell Programming and Scripting The loop does not run as expected Post 302078523 by nir_s on Saturday 1st of July 2006 03:33:49 PM
Old 07-01-2006
The loop does not run as expected

Hi folks,

I have the following configuration file:
Code:
DB_LAYER=NO
ADMIN_LAYER=NO
RTESUB_LAYER=NO
DB_HOST_NAME=tornado
ADMIN_HOST_NAME=tornado
RTESUB_HOST_NAME=tornado
RESPONSE_FILE_SR=/tmp/SR.rsp
INSTALL_SR_1=/home/Upgrade_4.7.1/Utilities/Install_SR:Y
INSTALL_SR_2=/home/Upgrade_4.7.2/Utilities/Install_SR:Y
INSTALL_SR_3=/home/Upgrade_4.8/Utilities/Install_SR:Y
INSTALL_SR_4=/home/Upgrade_4.8.1/Utilities/Install_SR:Y

I need to do the following:
1. Run in loop on this file
2. find the lines which end with ":Y"
3. cut the path from the line
4. Change directory to the path and run a script

I wrote the following function:


Code:
run_install_sr()
{
cat ${CONF_FILE} | grep INSTALL_SR_ | grep :Y | while read line
do
  INSTALL_SR_DIR=`echo $line | cut -d= -f2 | cut -d: -f1`

  rcp ${RESPONSE_FILE_SR} ${DB_HOST_NAME}:/tmp >> $installLog
  rsh ${DB_HOST_NAME} "su - root -c \"cd ${INSTALL_SR_DIR} && ./Install_SR.ksh -f /tmp/${RESPONSE_FILE_SR##*/} -l database\"" | tee -a $installLog

  rcp ${RESPONSE_FILE_SR} ${ADMIN_HOST_NAME}:/tmp >> $installLog
  rsh ${ADMIN_HOST_NAME} "su - root -c \"cd ${INSTALL_SR_DIR} && ./Install_SR.ksh -f /tmp/${RESPONSE_FILE_SR##*/} -l administration\"" | tee -a $installLog

  if [[ ${RTESUB_LAYER} = 'YES' ]] && [[ ${ADMIN_LAYER} = 'YES' ]] ; then
     rcp ${RESPONSE_FILE_SR} ${RTESUB_HOST_NAME}:/tmp >> $installLog
     rsh ${RTESUB_HOST_NAME} "su - root -c \"cd ${INSTALL_SR_DIR} && ./Install_SR.ksh -f /tmp/${RESPONSE_FILE_SR##*/} -l subscriber\"" | tee -a $installLog
  fi
done
}

The expected results : the loop suppose to run 4 times
The current results: the loop ran only once and issue the first line the loop found.
Does someone see something wrong?

Thanks in advance,
Nir
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script doesn't work as expected when run on cron

The script checks for free space stats on Oracle. If there are any tablespaces with more than 85% usage it prints the details of the tablespace. If all the tablespaces have more than 15% free space, then "All tablespaces have more than 15 pct free space" must be printed on the screen. When I run... (2 Replies)
Discussion started by: RoshniMehta
2 Replies

2. 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

3. Shell Programming and Scripting

How To Run A For Loop In A Remsh?

Hi all, I'm trying to remsh to another server and then execute a for loop command there but I'm getting unexpected errors and would appreciate any suggestions. Ideally what I want to do is this: for host in `cat host_file` do remsh $host -n " cd /home/ for DATABASE in `ls -d... (5 Replies)
Discussion started by: Korn0474
5 Replies

4. Shell Programming and Scripting

For loop to run external program

Hi, I was hoping for help with a for loop to run a program (vina) repeatedly using all the files in a folder as input. Currently my code looks like this: #!/bin/bash FILES=/home/afalk/Desktop/battest/*.pdbqt for f in $FILES do vina --config /home/afalk/Desktop/A.txt --ligand "$f".pdbqt done... (5 Replies)
Discussion started by: oldmanwinter
5 Replies

5. Shell Programming and Scripting

How do I run a shell command in a while loop?

The command is: sic -h irc.freenode.net 2>&1 | tee -a irc.log Where sic is an IRC client, and I'm piping the output to tee in order to log my IRC sessions. I'm trying to handle reconnects by running it in a while loop in the shell process and cat the initial commands into sic's stdin. I... (1 Reply)
Discussion started by: guitarscn
1 Replies

6. 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

7. Shell Programming and Scripting

How to run it in the loop??

I have this code awk -F, ' { C5+=$5 C6+=$6 C7+=$7 C8+=$8 R=$5+$6+$7+$8 T+=R } { print $0,R } END { print... (7 Replies)
Discussion started by: nikhil jain
7 Replies

8. Shell Programming and Scripting

Run the for loop in parallel

I have the below code which runs on multiple databases , but this runs one-after-one. I will need this to run in parallel so that i could save a lot of time. Please help!!! Thanks in advance for Db in `cat /var/opt/oracle/oratab |egrep -v "ASM" |grep -v \# |cut -d\: -f1` do { export... (5 Replies)
Discussion started by: jjoy
5 Replies

9. Shell Programming and Scripting

Trying to run a basic for loop

OS : RHEL 6.1 Shell : Bash I had a similair post on this a few weeks back. But I didn't explain my requirements clearly then. Hence starting a new thread now. I have lots of files in /tmp/stage directory as show below. I want to loop through each files to run a command on each file. I... (8 Replies)
Discussion started by: kraljic
8 Replies

10. Shell Programming and Scripting

For loop not giving expected output

#cat /tmp/input old_array old_dev new_dev new_array 0577 008AB 01744 0125 0577 008AC 01745 0125 0577 008AD 005C8 0125 0577 008AE 005C9 0125 0577 008AF 005CA 0125 0577 008B0 005CB 0125 0577 008B1 005CC 0125 cat test.sh #!/bin/ksh... (4 Replies)
Discussion started by: mbak
4 Replies
.K5LOGIN(5)							File Formats Manual						       .K5LOGIN(5)

NAME
.k5login - Kerberos V5 acl file for host access. DESCRIPTION
The .k5login file, which resides in a user's home directory, contains a list of the Kerberos principals. Anyone with valid tickets for a principal in the file is allowed host access with the UID of the user in whose home directory the file resides. One common use is to place a .k5login file in root's home directory, thereby granting system administrators remote root access to the host via Kerberos. EXAMPLES
Suppose the user "alice" had a .k5login file in her home directory containing the following line: bob@FUBAR.ORG This would allow "bob" to use any of the Kerberos network applications, such as telnet(1), rlogin(1), rsh(1), and rcp(1), to access alice's account, using bob's Kerberos tickets. Let us further suppose that "alice" is a system administrator. Alice and the other system administrators would have their principals in root's .k5login file on each host: alice@BLEEP.COM joeadmin/root@BLEEP.COM This would allow either system administrator to log in to these hosts using their Kerberos tickets instead of having to type the root pass- word. Note that because "bob" retains the Kerberos tickets for his own principal, "bob@FUBAR.ORG", he would not have any of the privileges that require alice's tickets, such as root access to any of the site's hosts, or the ability to change alice's password. SEE ALSO
telnet(1), rlogin(1), rsh(1), rcp(1), ksu(1), telnetd(8), klogind(8) .K5LOGIN(5)
All times are GMT -4. The time now is 12:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy