Sponsored Content
Full Discussion: 2 shells in one file
Top Forums Shell Programming and Scripting 2 shells in one file Post 302922956 by cmccabe on Wednesday 29th of October 2014 01:02:27 PM
Old 10-29-2014
Currently I have two different shell files (one that converts files and one annotates).

The conversion shell is:
Code:
 #!/bin/bash
while true
do
        printf "Enter ID  : " ; read id
        cd 'C:\Users\cmccabe\Desktop\annovar'
        [ -z "$id" ] && break
        [ "$id" = "end" ] && break
        perl convert2annovar.pl -includeinfo -format vcf4old ${id}_matched.vcf > ${id}_matched.avinput
done

and allows the user to enter the id of the file to be converted without knowing the code.

The annotation shell:
Code:
 #!/bin/bash
	    while true
	do
		printf "Is this a batch or sanger analysis :" ; read id
		cd 'C:\Users\cmccabe\Desktop\annovar'
        case "$id" in
        [yY])  perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo")' < file.txt 
                ;;
        [nN]) # code for X
                printf "Enter ID  : " ; read id
				cd 'C:\Users\cmccabe\Desktop\annovar'
                [ -z "$id" ] && break
                [ "$id" = "end" ] && break
				perl table_annovar.pl ${id}_matched.avinput humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo
                ;;
        end)  break ;;
        *)     ;; # Unknown option, do nothing
		esac
		printf "Is this a batch or sanger analysis :"
	done

allows the user to enter a batch or individual analysis without knowing the code.

---------- Post updated at 12:02 PM ---------- Previous update was at 11:07 AM ----------

Currently I have two different shell files (one that converts files and one annotates).

The conversion shell is:
Code:
 #!/bin/bash
      while true
do
        printf "Enter ID  : " ; read id
        cd 'C:\Users\cmccabe\Desktop\annovar'
        [ -z "$id" ] && break
        [ "$id" = "end" ] && break
        perl convert2annovar.pl -includeinfo -format vcf4old ${id}_matched.vcf > ${id}_matched.avinput
done

and allows the user to enter the id of the file to be converted without knowing the code.

The annotation shell:
Code:
 #!/bin/bash
	    while true
	do
		printf "Is this a batch or sanger analysis :" ; read id
		cd 'C:\Users\cmccabe\Desktop\annovar'
        case "$id" in
        [yY])  perl -ne 'chomp; system ("perl table_annovar.pl $_ humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo")' < file.txt 
                ;;
        [nN]) # code for X
                printf "Enter ID  : " ; read id
				cd 'C:\Users\cmccabe\Desktop\annovar'
                [ -z "$id" ] && break
                [ "$id" = "end" ] && break
				perl table_annovar.pl ${id}_matched.avinput humandb/ -buildver hg19 -protocol refGene,popfreq_all,common,clinvar,clinvarsubmit,clinvarreference -operation g,f,f,f,f,f -otherinfo
                ;;
        end)  break ;;
        *)     ;; # Unknown option, do nothing
		esac
		printf "Is this a batch or sanger analysis :"
	done

allows the user to enter a batch or individual analysis without knowing the code.

What I am trying to do is combine the two into one shell and based off of user input "y or n" different commands are run.

For example, the user is asked if the file needs to be converted and type "y", so a script associated with a "y" response is run
Code:
 perl convert2annovar.pl -includeinfo -format vcf4old ${id}_matched.vcf > ${id}_matched.avinput

that part of the code loops unless "n" is typed then it skips to line 14. I hope this helps and thank you Smilie.
This User Gave Thanks to cmccabe For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Shells

I have came across the definitions of these shells korn bourne c etc .. but honestly till now i din't get the exact difference between these threes , the advantages ..... can anyone pinpoint me where it actually lies ..... don;t include me answers like aliasing in c is posible and not in bourne ..... (3 Replies)
Discussion started by: dino_leix
3 Replies

2. Linux

Version of Shells?

Can anyone tell me the version of shells for bash mc pdksh tcsh zsh For Red Hat Enterprise 4? Thank you very much! (2 Replies)
Discussion started by: Xplore
2 Replies

3. UNIX for Advanced & Expert Users

why we have different shells?

Can you pls. tell me, why we have different shells in UNIX OS ( Eg. SunOs) and also I would like to know what is the specific difference b/w SVR and BSD ? Thanks. (2 Replies)
Discussion started by: shahnazurs
2 Replies

4. Linux

/etc/shells on /etc/passwd

Hi All, Why does these list (below) doesn't belong to /etc/shells? sync:x:5:0:********************// :/sbin:/bin/sync shutdown:x:6:0:********************// :/sbin:/sbin/shutdown halt:x:7:0:********************// :/sbin:/sbin/halt webalizer:x:68:68:***************// ... (2 Replies)
Discussion started by: itik
2 Replies

5. Shell Programming and Scripting

find all of the available shells

To find all of the available shells in your system we can use cat /etc/shells but i dont find shells in my system where else i can look for same info?? (4 Replies)
Discussion started by: Deepak Dutt
4 Replies

6. UNIX for Dummies Questions & Answers

The /etc/shells file is missing.

Hi the /etc/shells file is missing on some of development boxes. Is this ok? Where can I find this file? ---------- Post updated at 07:07 AM ---------- Previous update was at 07:07 AM ---------- I have solaris, linux, aix and hpux machines and on all of these machines the /etc/shells file is... (8 Replies)
Discussion started by: manju--
8 Replies

7. UNIX for Dummies Questions & Answers

shells and scripts

So in UNIX, I understand that there are several different shells you can be in: C, Bourne, Bourne Again, Korn, etc. I also know that you can write scripts for the shells, by assigning it by #!/bin/csh, or sh, etc. If I am working in the csh, do I have to write the script for the csh? Or can it... (1 Reply)
Discussion started by: bjstaff
1 Replies

8. UNIX for Dummies Questions & Answers

Shells

Lets say my default shell is bash and then i load up csh and then ksh. How would i exit csh without exiting ksh? so basically i gone from bash > csh > ksh and i wish to close csh (2 Replies)
Discussion started by: Bill Thompson
2 Replies

9. UNIX for Dummies Questions & Answers

Significance of different shells?

I'm taking a LINUX and UNIX class and we are using bash as the shell in terminal. On my mac-book I use zsh only because my professor had a pretty cool start-up file for it. It has benefited me in becoming familiar with different shells. However, I'm having a hard time understanding the purpose... (4 Replies)
Discussion started by: syregnar86
4 Replies

10. UNIX for Dummies Questions & Answers

Please what are shells?

I mean like this: http://shells.red-pill.eu/ Can anyone explain how this works? I hope my post is not spam. I think its related to linux. Thank you (1 Reply)
Discussion started by: postcd
1 Replies
All times are GMT -4. The time now is 10:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy