Select command going to infinite loop after running the script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Select command going to infinite loop after running the script
# 1  
Old 07-03-2014
Select command going to infinite loop after running the script

Code:
cd /opt/et/WAS/apps/8.0
find . -name "HostIntegration.properties" -o -name "HostSocket.properties" -o -name "environment.properties" 2> /dev/null | awk -F '[//]' '{print $4}'|awk '!x[$0]++' | cat>/home/cbadmin/file1.txt
cd /home/cbadmin/
PS3='Please enter a number from list of applications==>:'
select var1 in `cat /home/cbadmin/file1.txt`
do
echo "select app from the list $var1"
i=$var1
done
echo $i
/usr/local/bin/pbrun /opt/et/WAS/apps/8.0/q/ET_scripts/chgperm.sh unlock $i

file1.txt differs everytime based upon the find command.
I need to use the unlock command.but it's going to infinite loop if i run the scipt.It's not going to another step.Could some one please help me on this.

Output of the code:
Code:
bash-3.00$ ./test.sh
1) ces1
2) ib
3) rassa
4) 53com-misc
5) ofx
6) open-consumer
Please enter a number from list of applications==>:1
select app from the list ces1
Please enter a number from list of applications==>:

# 2  
Old 07-03-2014
To exit the loop use the break command. I'd also check for illegal input. With some other minor changes your code could be rewritten to:
Code:
find /opt/et/WAS/apps/8.0 -name "HostIntegration.properties" -o -name "HostSocket.properties" -o -name "environment.properties" 2>/dev/null | awk -F '[//]' '{print $4}'|awk '!x[$0]++' >/home/cbadmin/file1.txt
cd /home/cbadmin/
PS3='Please enter a number from list of applications==>:'
select var1 in `cat /home/cbadmin/file1.txt`
do
   if [ $var1 != "" ]; then
      echo "The selected app from the list is: $var1" 
      break
   else
      echo "Illegal selection."
   fi
done
/usr/local/bin/pbrun /opt/et/WAS/apps/8.0/q/ET_scripts/chgperm.sh unlock $var1

# 3  
Old 07-03-2014
Select is meant to run in an infinite loop until it reads EOF from stdin or the break command is issued. Try e.g.
Code:
select var1 in `cat filelist` end
do [ "$var1" == "end" ] && break
... your command list ...
done

# 4  
Old 07-03-2014
Thanks a lot Cero.It's working fine to me..

---------- Post updated at 10:17 AM ---------- Previous update was at 10:16 AM ----------

Thanks for your valuable information Rudic.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read function is going in infinite in another script having while loop

Hello Experts, I have created one user confirmation process that will ask for user input. I have created one func for it. The issue is if i call it as normal then it works fine but if i am calling it in another script(in while loop) . It is going in infinite loop and not asking for user input. ... (8 Replies)
Discussion started by: looney
8 Replies

2. Programming

Nmap shell script goes in infinite loop

My script’s output goes in infinite loop Below is my script: Nmap() { while read -r line do name="$line" echo "$name" count=$line nmap -oG output.txt -T4 -f -iL iplist.txt $line1 done < iplist.txt } Nmap ................................................................. ... (2 Replies)
Discussion started by: sk151993
2 Replies

3. Shell Programming and Scripting

Calling a script from a shell that needs to cancel out of infinite loop

I am writing a shell script that calls this oracle utility to get some information about the DB that I need for the script https://docs.oracle.com/cd/B16240_01/doc/em.102/e15294/options.htm This is the command that I am running: $ORACLE_HOME/OPatch/opatch lsinventory -details | grep -i... (1 Reply)
Discussion started by: guessingo
1 Replies

4. Shell Programming and Scripting

Infinite while loop script shows more than one process

Hi, I have a script which triggers an infinite loop. #!bin/bash trig=`ls /home/trig.tch |wc -l` function callj { some commands... } while do callj & done The number of process after doing a ps -ef |grep Mon.sh returns processes even after the script is killed by deleting the... (4 Replies)
Discussion started by: chetan.c
4 Replies

5. Shell Programming and Scripting

Script with infinite loop stops after sometime

Hi I am working on a server that is set up and maintained by a third party. It seems whenever I run bash scripts in the background (with a &) with while loops in them they seem to me killed in around 2.5 hours. ( I am running them as a normal user with no special privileges ) . Is there a... (3 Replies)
Discussion started by: pkabali
3 Replies

6. Shell Programming and Scripting

Infinite while loop

what is the difference between while:,while true and while false? (6 Replies)
Discussion started by: proactiveaditya
6 Replies

7. Shell Programming and Scripting

Script to run infinite loop

Hi all, I have a script which triggers batch admin manager and gets the top 10 jobs and their status info. the output of this script is the list of all these jobs. I want to run this in infinite loop which will show top 100 jobs' status. the script is as follows #!/bin/sh exec &> capture1.txt... (1 Reply)
Discussion started by: digitalrg
1 Replies

8. Shell Programming and Scripting

infinite loop to check process is running

Hi, I got a simple script working to check if a process is running and then email if it is not running anymore. My scenario is that I need to make sure the process is always running so instead of running the below script via cron I think it is better to a have a looping script to check... (12 Replies)
Discussion started by: yabai
12 Replies

9. Shell Programming and Scripting

Running a script in INFINITE LOOP

Hi All, I have a requirement as below. I supposed to get a file from Source system once in a month. But we dont know when the source system will send the file. My script has to wait for that file in LOOP once it gets the file then it has to FTP the file. I thought of scheduling the job... (5 Replies)
Discussion started by: Raamc
5 Replies

10. Solaris

ls command in infinite Loop

Hi, whenever I am giving a 'ls' command system is going into infinite loop displaying the current home directory. There is no separate shell script/file with ls name anywhere in the system. I am using Solaris 10. Any help / guidance in solving this problem is highly appreciated. ... (3 Replies)
Discussion started by: umakant
3 Replies
Login or Register to Ask a Question