# Function Bug in script - need help

**URL:** https://community.unix.com/t/function-bug-in-script-need-help/171752
**Category:** Shell Programming and Scripting
**Created:** [June 4, 2007, 4:18pm UTC](https://community.unix.com/t/function-bug-in-script-need-help/171752 "2007-06-04T16:18:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![gzs553](https://community.unix.com/letter_avatar/gzs553/32/5_5575768a8748004e209b776fc1b2916d.png) [@gzs553](https://community.unix.com/u/gzs553)
#### Post date: [June 4, 2007, 4:18pm UTC](https://community.unix.com/t/function-bug-in-script-need-help/171752/1 "2007-06-04T16:18:03Z")

</div>

My script is erroring with: testtapemgr.sh: FTP\_RETURNS: not found  
I cannot see what I am doing wrong..when it calls that function from the Volume returns function and says taht FTP\_RETURNS is not found and exits out of the script. What am I not seeing here?

#### Return Volume Function Section ############  
Volume\_Returns()  
{  
echo "Enter Volumes to be returned"; read input  
total\_ret=`mminfo -q volume=$input -r volume,location,pool,volretent \> $ERVTAPE_RET; cat $ERVTAPE_RET | wc -l`  
echo "Is this the volume you would like to return.. $input (y/n)"  
total\_ret=`expr $total_ret - 1`  
echo " Please return the tapes listed"| cat $ERVTAPE\_RET  
read response  
if [$response = "y"]; then  
echo "Please return the following Tape(s)" \>\>$ERVTAPE\_RET   
echo " Please return the tapes listed"| cat $ERVTAPE\_RET  
RETURN\_FLAG="y"  
CUT\_ERVTAPE\_FILE;  
#EMAIL\_ERV\_RET;  
FTP\_RETURNS

```
else 
	echo "incorrect response"; Volume_Returns
	exit
fi

```

}

########################### OFFSITE VOLUMES TO BE RETURNED  
FTP\_RETURNS()  
{  
echo "In ftp\_ret routine"  
echo "$ERVTAPE\_RTMP File Transferring to $FTP\_HOST.................Return\_TAPES"  
ftp -n $FTP\_HOST \<\<END\_FTP\_RET  
quote USER $FTP\_LOGIN  
quote PASS $FTP\_PWD  
put $ERVTAPE\_RTMP  
put $RETURN\_TAPES\_RPT  
rename $ERVTAPE\_RTMP /export/home/legato/tapemgr/rpts/offsite/returns/ERVTAPE\_return.tmp  
rename $RETURN\_TAPES\_RPT /export/home/legato/tapemgr/rpts/offsite/returns/returns\_erv.rpt$dat  
echo $ERVTAPE\_RTMP; echo $RETURN\_TAPES\_RPT  
END\_FTP\_RET  
}  
clear  
tapemgr\_Main\_Menu

---

<div class="post-metadata">

### Author: ![Ygor](https://community.unix.com/user_avatar/community.unix.com/ygor/32/104_2.png) [@Ygor](https://community.unix.com/u/Ygor)
#### Post date: [June 4, 2007, 9:55pm UTC](https://community.unix.com/t/function-bug-in-script-need-help/171752/2 "2007-06-04T21:55:29Z")

</div>

You must first define the function before calling it.

---

<div class="post-metadata">

### Author: ![gzs553](https://community.unix.com/letter_avatar/gzs553/32/5_5575768a8748004e209b776fc1b2916d.png) [@gzs553](https://community.unix.com/u/gzs553)
#### Post date: [June 4, 2007, 10:36pm UTC](https://community.unix.com/t/function-bug-in-script-need-help/171752/3 "2007-06-04T22:36:18Z")

</div>

Not sure what you mean. I did define the function as

FTP\_RETURNS()

..see the script where I call the function.

---

<div class="post-metadata">

### Author: ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)
#### Post date: [June 4, 2007, 10:55pm UTC](https://community.unix.com/t/function-bug-in-script-need-help/171752/4 "2007-06-04T22:55:58Z")

</div>

the function should be defined BEFORE it's being CALLED

---

<div class="post-metadata">

### Author: ![gzs553](https://community.unix.com/letter_avatar/gzs553/32/5_5575768a8748004e209b776fc1b2916d.png) [@gzs553](https://community.unix.com/u/gzs553)
#### Post date: [June 5, 2007, 1:35am UTC](https://community.unix.com/t/function-bug-in-script-need-help/171752/5 "2007-06-05T01:35:34Z")

</div>

Gosh...sometimes I am so dense...Thanks for your help!! I guess I have been looking at it too long....duh!! :eek:
