Bash calling a few functions syntax error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash calling a few functions syntax error
# 1  
Old 03-28-2017
Bash calling a few functions syntax error

In the bash function below if the user selets "y" then the menu function is called and if they select "n" the move function is called. That all seems to work, my question is after the files are moved an echo,
line in bold is displayed and another function called backup is called. I am getting a syntax error on that line as that function, backup, can not be found. After the backup function executes another function
run is called, hopefully. It seems very close but I'm not sure if I have the syntax for making the calls correct. Thank you Smilie.

Code:
additional() {
    printf "\n\n"
    printf "Are there additional files to be analyzed?  Y/N "; read match_choice

    case "$match_choice" in
        [yY]) menu; break;;
        [nN]) move; printf "Select folders are being copied to MedexPatients on medex as well as to the import folders "; break;;
    esac
}

move() {
# move specific folders to MedexPatients on medex CIFS share
mkdir -p /home/cmccabe/medex/MedexPatients/$filename
rsync -av --exclude='/home/cmccabe/Desktop/NGS/API/$filename/bedtools' --exclude='/home/cmccabe/Desktop/NGS/API/$filename/torrent' --exclude='/home/cmccabe/Desktop/NGS/API/$filename/igv' /home/cmccabe/Desktop/NGS/API/$filename/bam /home/cmccabe/Desktop/NGS/API/$filename/fastqc /home/cmccabe/Desktop/NGS/API/$filename/lowcoverage /home/cmccabe/Desktop/NGS/API/$filename/panel /home/cmccabe/Desktop/NGS/API/$filename/picard /home/cmccabe/Desktop/NGS/API/$filename/vcf /home/cmccabe/Desktop/NGS/API/$filename/*.txt /home/cmccabe/Desktop/NGS/API/$filename/*.pdf /home/cmccabe/Desktop/NGS/API/$filename/*.log /home/cmccabe/medex/MedexPatients/$filename

# move to GenePerecent on CIFS share medex
rsync -av /home/cmccabe/Desktop/NGS/API/$filename/panel/20x/percent/*.txt /home/cmccabe/medex/GenePercent

# move to LowCoverage
rsync -av /home/cmccabe/Desktop/NGS/API/$filename/lowcoverage/20x/*.txt /home/cmccabe/medex/LowCoverage

# move to MedexVariants
rsync -av /home/cmccabe/Desktop/NGS/API/$filename/vcf/panel/annovar/*.txt /home/cmccabe/medex/MedexVariants

# move to Quality Metrics
rsync -av /home/cmccabe/Desktop/NGS/API/$filename/pdf/*.txt /home/cmccabe/medex/QualityMetrics

echo "analysis complete with new folder created and files moved to medex, the folder will now be sent to archive : $(backup)"
}

backup() {
# move folder to backup
printf "\n The directory will be moved to backup "; mv -v /home/cmccabe/Desktop/NGS/API/$filename /media/cmccabe/"My Book Western Digital"/ClinicalRuns; run ;;
}


Last edited by cmccabe; 03-28-2017 at 12:55 PM.. Reason: fixed format
# 2  
Old 03-28-2017
backup has to be declared before you call it - functions are best put to near the very topof a script file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

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

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

3. Shell Programming and Scripting

Calling Bash Functions in the BG

I'm trying to call some functions in the background so that I can multitask in this script. Not working so hot. The functions I call don't ever seem to get called. I'm doing it the exact same way in another script and it's working like a champ so I'm very confused. Here's a pretty simple repro: ... (7 Replies)
Discussion started by: stonkers
7 Replies

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

5. Shell Programming and Scripting

Calling multiple functions in parallel

Hello, I have multiple functions within a shell script. eg. function_database_backup, unix_tar_creation, etc. I would like to run these functions in parallel, as each is independent of the other. If these were simple commands, I could have probably run each of the commands in background. ... (1 Reply)
Discussion started by: neil.k
1 Replies

6. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

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

8. Shell Programming and Scripting

Calling Functions of Other K Shell Program

Hi, I have a K shell a.ksh function abc { // Some logic } In b.ksh i have included the a.ksh ./a.ksh I want to call the abc function from this b.ksh script. Thanks Vijay (2 Replies)
Discussion started by: vijaykrc
2 Replies

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

10. Shell Programming and Scripting

Calling functions in scripts directly

Hi, I have a menu driven script that does various tasks, I want to be able to call functions directly from within other unix scripts from my menu script. Is this possible? (12 Replies)
Discussion started by: LiquidChild
12 Replies
Login or Register to Ask a Question