Sponsored Content
Top Forums Shell Programming and Scripting Bash function using variable in it syntax error Post 302994493 by cmccabe on Thursday 23rd of March 2017 01:08:52 PM
Old 03-23-2017
Code:
menu() {
    while true
    do
        printf "\n Welcome to target gene annotation and mutalyzer (v1), please make a selection from the MENU \n
        ==================================
        \t 1  GJB2 analysis
        \t 2  MECP2 analysis
        \t 3  Phox2B analysis
        \t 4  CAP annotation
        \t 5  Non-target gene
        \t 6  Syntax checker
        \t 7  Name checker
        \t 8  Position converter
        ==================================\n\n"

        printf "\t Your choice: "; read menu_choice

        case "$menu_choice" in
        1) gjb2 ;;
        2) mecp2 ;;
        3) phox2b ;;
        4) cap ;;
        5) non ;;
        6) syntax ;;
        7) name ;;
        8) position ;;
        *) printf "\n Invalid choice."; sleep 2 ;;
        esac
    done
}

cap() {
CODING=/home/cmccabe/cap/TGS/NM.txt
SAMPLE=/home/cmccabe/cap/TGS
SURVEY=/home/cmccabe/cap/TGS

printf "The survey being used is and here are the details:" "$SURVEY\survey.txt "

PS3="please select a file to analyze with a panel: "

cd "$SAMPLE"
select file1 in $(cat samples.txt)
do	[ "$file1" != "" ] && break
done
      printf "FILE is: ${file1} and will be used for annotation\n"
      read -r -p "Is this correct? [y/N] " response
if [[ $response =~ ^[nN][oO]?$ ]]
then
echo 'please try again'  && return
    printf "\n\n"
    printf "What is the id of the CAP sample getting gene annotation : "; read id
	printf "Please enter the variant(s), the following are examples"
	echo " c.274G>T or c.274-10G>T or c.*18_*19delGCinsAA"
	
	printf "and please use a comma between multiple: "; IFS="," read -a variant
        
        [ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && return
        [ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && return

        for ((i=0; i<${#variant[@]}; i++))
              do printf "${CODING}:%s\n" "${variant[$i]}" 
        done >> /home/cmccabe/cap/TGS/out.txt
}

# actual start of this program
menu # run menu function
/home/cmccabe/Desktop/annovar.sh: line 65: syntax error near unexpected token `}'
/home/cmccabe/Desktop/annovar.sh: line 65: `}'

I mispoke on the error message, but did test the menu call and that executes perfectly. Thank you Smilie.

Also, you were correct ... ${variant[]} is not intended to split.

Last edited by cmccabe; 03-23-2017 at 02:10 PM.. Reason: added comment
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash: how to call function having it's name in variable?

Hello. Looking for a method of modularizing my bash script, I am stuck with such a problem. For example, I have: MODULE_NAME="test" FUNCTION_NAME="run" How do I can a function with name test_run? (4 Replies)
Discussion started by: FractalizeR
4 Replies

2. Shell Programming and Scripting

BASH Script syntax error

I'm trying to write a simple script that takes all the .tar.gz files in a directory and verifies them by using the gzip -tv command: for zip in *.tar.gz do gzip -tv $zip if ; then #Check return code from tar echo "File ${zip} verified OK." exit... (4 Replies)
Discussion started by: kelldan
4 Replies

3. Shell Programming and Scripting

bash syntax error: command not found

I am trying to create a shell that asks the user to enter their name, and compare it to my own by saying we have the same name or saying my name and that they have a nice name too. Here is my script... #!/bin/bash-x echo "Enter your name". read name if then echo "My name is Adam too"... (1 Reply)
Discussion started by: amaxey45
1 Replies

4. Shell Programming and Scripting

Syntax Error while using CMP function

Hi All, I am getting a syntax error message while trying to compare 2 files using the compare function (LINUX) command substitution: line 79: syntax error near unexpected token `(' command substitution: line 79: `cmp -s <(tr , \n < $COMMON_TMP/nt_per_gs.done | sort) <(tr , \n <... (5 Replies)
Discussion started by: dsfreddie
5 Replies

5. Shell Programming and Scripting

Variable syntax error in $?

hi all , i just tried to take the status of previous command inside the script using echo $?. It throws me a variable syntax error , but when i use echo $? as an individual command it works perfectly . can anyone Please tell me why am getting a variable syntax error when i use echo $?... (7 Replies)
Discussion started by: Rahul619
7 Replies

6. Shell Programming and Scripting

BASH: variable and function scope and subscripts

Hi, I'm a Delphi developer new to linux, new to this forums and new to BASH programming and got a new task in my work: maintaining an existing set of BASH scripts. First thing I want to do is making the code more reliable as in my opinion it's really bad written. So here's the quest: I'm... (6 Replies)
Discussion started by: rse
6 Replies

7. Shell Programming and Scripting

Function works, trigger causes syntax error, whats my fault??

Needing a hint. Creating that function called Meter my simple script works well. What I want now is to start the last four commented lines to include or trigger a reaction, if there are more than n lines in that .txt-file it shall display that message for example. But the interpreter says there is... (3 Replies)
Discussion started by: 1in10
3 Replies

8. Shell Programming and Scripting

Bash syntax error

while read line do mkdir $line scp -r Docking_results/docking_$line.pdb $line/ cd /$line/ set a=`grep ENDMDL docking_'$line'.pdb | wc -l` set b=`expr $a - 2` csplit -k -s -n 3 -f docking_'$line'. docking'$line'.pdb '/^ENDMDL/+1' '{'$b'}' foreach f (... (4 Replies)
Discussion started by: chrisjorg
4 Replies

9. Shell Programming and Scripting

-bash: syntax error near unexpected token `('

// AIX 6.1 I am getting a syntax error below. Please advise what to be corrected. :confused: runmqsc CERN.$(echo `hostname` | cut -d'.' -f1 | tr '' '').$(echo $environment | tr '' '') <<! | egrep -i '(FROM.NC.APPLIANCE)' | sort -u |awk '{print $2}' | cut -d '(' -f2 | cut -d ')' -f1 |... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

10. Shell Programming and Scripting

Syntax error in subtraction in Bash

I am sharing a code snippet. for (( i=0; i<=$(( $count -1 )); i++ )) do first=${barr2} search=${barr1} echo $first echo "loop begins" for (( j=0; j<=5000; j++ )) do if } == $search ]]; then echo $j break; fi done second=${harr2} echo $second (2 Replies)
Discussion started by: ngabrani
2 Replies
Tk_GetCapStyle(3)					       Tk Library Procedures						 Tk_GetCapStyle(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tk_GetCapStyle, Tk_NameOfCapStyle - translate between strings and cap styles SYNOPSIS
#include <tk.h> int Tk_GetCapStyle(interp, string, capPtr) const char * Tk_NameOfCapStyle(cap) ARGUMENTS
Tcl_Interp *interp (in) Interpreter to use for error reporting. const char *string (in) String containing name of cap style: one of "butt", "projecting", or "round". int *capPtr (out) Pointer to location in which to store X cap style corresponding to string. int cap (in) Cap style: one of CapButt, CapProjecting, or CapRound. _________________________________________________________________ DESCRIPTION
Tk_GetCapStyle places in *capPtr the X cap style corresponding to string. This will be one of the values CapButt, CapProjecting, or CapRound. Cap styles are typically used in X graphics contexts to indicate how the end-points of lines should be capped. See the X docu- mentation for information on what each style implies. Under normal circumstances the return value is TCL_OK and interp is unused. If string does not contain a valid cap style or an abbrevia- tion of one of these names, then an error message is stored in interp->result, TCL_ERROR is returned, and *capPtr is unmodified. Tk_NameOfCapStyle is the logical inverse of Tk_GetCapStyle. Given a cap style such as CapButt it returns a statically-allocated string corresponding to cap. If cap is not a legal cap style, then "unknown cap style" is returned. KEYWORDS
butt, cap style, projecting, round Tk Tk_GetCapStyle(3)
All times are GMT -4. The time now is 07:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy