Sponsored Content
Full Discussion: Code exits before completing
Top Forums Shell Programming and Scripting Code exits before completing Post 302940365 by Peasant on Saturday 4th of April 2015 01:38:04 AM
Old 04-04-2015
You should try to be consistent when using printf, use always same format.
Return IFS to old value, it is good practice so you don't get surprises in code later on.

As the volume of elifs increases the code will be harder to maintain with a higher margin for error.

Use case perhaps ?

Code:
case $gene in
	GJB2)
		code="NM_004004.5"
	;;
	MECP2)
		code="NM_004992.3"
	;;
	Phox2B)
		code="NM_003924.3"
	;;
	*) # everything else we do not won't to process.
		printf "%s \n" "This is not a target ..."
	;;
esac
printf "%s \n" "Enter variant(s): "
OLDIFS=$IFS
IFS=","
read -a variants
for (( i = 0; i < ${#variants[@]}; i++ ))
	do
	printf "%s %s\n" "$code" "${variants[$i]}" # is plain redirection ok here instead of using tee ?
	done
IFS=$OLDIFS

If users are providing input to your scripts, i would recommend using getopts and passing those via command line e.g ./myscript -a $gene -b variant1,variant2

Reason is simple, if you ever decide to automate the input (predefined input for all variables) it will be simple, opposing to using approach you are using now.

Hope that helps
Regards
Peasant.
This User Gave Thanks to Peasant For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Terminate session on completing script

Hai all.. How do i terminate my telnet session automatically when my java applicatiion exits. i have a file run which executes my java application and takes care of all class and library path settings prior to the execution. I would like to terminate my session when my application exits. The... (4 Replies)
Discussion started by: deepsteptom
4 Replies

2. UNIX for Dummies Questions & Answers

Completing ffmpeg installation

Hello. i am new to unix, though have quite a substantial background of other systems. i recently installed ffmpeg and mencoder on a unix server, which holds a website, in order to use these programs from the website. after installation, i can activate both commands directly using putty, no... (1 Reply)
Discussion started by: noamon
1 Replies

3. Shell Programming and Scripting

tcsh + completing a sub-directory entry

As part of a script Im designing, I am required to allow the command line to finish off part of a series of sub-directory entries. Basically what I want to do is cp /root/parent/part of subs name + other part of subs name/file /other_root/other_parent/other_sub/file without facing... (0 Replies)
Discussion started by: JamesGoh
0 Replies

4. UNIX for Dummies Questions & Answers

Completing Command Entry without Typing

Hi, In my UNIX (KSH) sytem, in order to Complete Command Entry without Typing the whole path or name, I have to use ESC+\ where as I am used to press TAB key to do the same. Can anyone tell me where we need to change the settings of the keyboard combination so that when I press TAB key the file... (6 Replies)
Discussion started by: jisha
6 Replies

5. Shell Programming and Scripting

shell script exiting before completing

I have a script which has the following statement, /opt/oracle/product/9i/bin/sqlplus << EOC >> $LOG_FILE 2>&1 username/password ---- Enters the SQL prompt @/export/home/oracle/shells/grant_userview.sql ---Runs the SQL script @/export/home/oracle/shells/grant_proc_userview.sql ---Runs the... (6 Replies)
Discussion started by: welldone
6 Replies

6. Homework & Coursework Questions

Help completing lab.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: ''you are missing the /home/smichaels/Labs/lab2b/group file, please create it as per step 12 of the lab. once... (4 Replies)
Discussion started by: ink
4 Replies

7. Shell Programming and Scripting

Looping not completing in shell script

Hi, Iam using below code to login to servers to get cpu utilisation. but output is coming for only one server. code is below root@blr-svr-oclan-01 # more SSSC_CPU_UTIL1.sh #!/bin/sh echo "CPU UTILIZATION" while read line; do IDLE=`/usr/local/bin/sshpass -p 'xxx' ssh xxx@$line 'sar 2 2' |... (1 Reply)
Discussion started by: surender reddy
1 Replies

8. Shell Programming and Scripting

Need help with completing a bash script

Hello All, I am automating a task using bash script and got stuck at this. From the below input, Meta Device Members (20) : { ---------------------------------------------------------------------- BCV DATA RDF DATA ... (7 Replies)
Discussion started by: Sam R
7 Replies

9. Shell Programming and Scripting

Bash not calling function after completing

In the below bash the function execute is started with the while true at the end of the script. Currently, this works and processing does begin. The function panel in bold does not get called after execute completes, therefore the user does not get the menu selection and the files just loop... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. What is on Your Mind?

Congratulations RudiC for completing 4000+ THANKS in forums.

Hello All forum members, I would like to take this opportunity to THANK RudiC for his tremendous achievement, guidance, help for helping in forums, let us join our hands together for his GREAT achievement :b: @Rudi sir, How are you sir? you ROCK, please keep up the great work sir :b: ... (1 Reply)
Discussion started by: RavinderSingh13
1 Replies
USERINFO(8)						    BSD System Manager's Manual 					       USERINFO(8)

NAME
userinfo -- displays user information SYNOPSIS
userinfo [-e] user DESCRIPTION
The userinfo utility retrieves the user information from the system. The userinfo utility is only available if built with EXTENSIONS. See user(8) for more information. The following command line option is recognised: -e Return 0 if the user exists, and non-zero if the user does not exist, on the system. No information is displayed. This form of the command is useful for scripts which need to check whether a particular user name or uid is already in use on the system. The user argument may either be a user's name, or a uid. EXIT STATUS
The userinfo utility exits 0 on success, and >0 if an error occurs. SEE ALSO
passwd(5), group(8), user(8), useradd(8), userdel(8) HISTORY
The userinfo utility first appeared in NetBSD 1.5. It is based on the addnerd package by the same author. AUTHORS
The userinfo utility was written by Alistair G. Crooks <agc@NetBSD.org>. BSD
November 16, 2005 BSD
All times are GMT -4. The time now is 01:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy