encryption script

I am encrypting and ftping files with kshell from aix and I have a problem with the job not waiting long enough before it ftps the files. when I run the script it sends the files over and each time the file has a different length and cannot be decrypted but if I encrypt and the manually send the file they are fine... I think I need a way to wait longer than the "wait" command gives me

function encrypt_test
{
cd $mydir
gpg --recipient $user --recipient $user2 --encrypt-files $file
}

mydir=/home/encrypt/test
usercd="<<encryptkeyhis>>"
usercd2="<<encrtptkeymine>>"
file=stmt_ll*.*

encrypt_test
wait

# -----------------------------------------------------------------------------
# put the files on the ftp server
#
# -----------------------------------------------------------------------------
cd $mydir
[[ $USER = "<<user>>" ]];
echo "user <<username>> <<password>>
cd /usr/ardentsam/backfiles
prompt
mput *.gpg
quit" | ftp -n <<IPADDRESS>>
rm .gpg
mv stmt_ll*.
$mydir/bkup

You should not need the wait at all, it is doing nothing since there isn't anything to wait for.

You are setting usercd and usercd2. Then you are using user and user2. Looks like to need to spell your variables right.

turns out that encryption does not like it when you ftp in ascii you need to ftp in Binary...

you should take a look at the perl module GnuPG

i use it and then i ftp files places.