Sponsored Content
Top Forums Shell Programming and Scripting Bash calling a few functions syntax error Post 302994809 by cmccabe on Tuesday 28th of March 2017 11:54:09 AM
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
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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
LIBBASH(7)							  libbash Manual							LIBBASH(7)

NAME
libbash -- A bash shared libraries package. DESCRIPTION
libbash is a package that enables bash dynamic-like shared libraries. Actually its a tool for managing bash scripts whose functions you may want to load and use in scripts of your own. It contains a 'dynamic loader' for the shared libraries ( ldbash(1)), a configuration tool (ldbashconfig(8)), and some libraries. Using ldbash(1) you are able to load loadable bash libraries, such as getopts(1) and hashstash(1). A bash shared library that can be loaded using ldbash(1) must answer 4 requirments: 1. It must be installed in $LIBBASH_PREFIX/lib/bash (default is /usr/lib/bash). 2. It must contain a line that begins with '#EXPORT='. That line will contain (after the '=') a list of functions that the library exports. I.e. all the function that will be usable after loading that library will be listed in that line. 3. It must contain a line that begins with '#REQUIRE='. That line will contain (after the '=') a list of bash libraries that are required for our library. I.e. every bash library that is in use in our bash library must be listed there. 4. The library must be listed (For more information, see ldbashconfig(8)). Basic guidelines for writing library of your own: 1. Be aware, that your library will be actually sourced. So, basically, it should contain (i.e define) only functions. 2. Try to declare all variables intended for internal use as local. 3. Global variables and functions that are intended for internal use (i.e are not defined in '#EXPORT=') should begin with: __<library_name>_ For example, internal function myfoosort of hashstash library should be named as __hashstash_myfoosort This helps to avoid conflicts in global name space when using libraries that come from different vendors. 4. See html manual for full version of this guide. AUTHORS
Hai Zaar <haizaar@haizaar.com> Gil Ran <ril@ran4.net> SEE ALSO
ldbash(1), ldbashconfig(8), getopts(1), hashstash(1) colors(1) messages(1) urlcoding(1) locks(1) Linux Epoch Linux
All times are GMT -4. The time now is 08:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy