problem with ftp mget

Hi
I am trying to ftp all the files from a directory in server2 to server1 (both unix) The below code is in server1

ftpfile=/home/anitha/ftptxt
echo cd mydir >>$ftpfile
echo mget *.* >>$ftpfile
cat $ftpfile | ftp -i server2

mydir is a directory in server2 and there are some test files in it.
when executing this code, the files in server1 is copied to mydir folder in server2. please let me know where im goin wrong. i have given the login details of server2 in the .netrc file in server1.

contents of $ftpfile:
cd mydir
mget sample.txt sample2.txt

sample.txt sample2.txt are files in server1. same output for mput as well.

Hi,

Pls check samle code like below,

login to Server2 and go to directory where file exits which you want to transfer,

ftp username@server1
passwd
cd directory
mget *.*
bye

above is simple code try this

Regards,
Srinivas Jala

I know that ur code will work fine. As this is a part of an automation script i cannot use urs. Please let me know what is wrong in the code posted by me.?

Hey Can give me excat code of FTP scrit? So that i can help you better.

Regards,
Srinivas Jala

When run from shell the *.* is being expanded by the shell in server1 to a list of filenames from the current directory.

To prove this, try a single line shell script. This does not work from the command line - it must be in a shell script.

echo mget *.*

Note that it only lists those files which contain a "." in their name.

We need to protect the asterisks from the shell by quoting them.

ftpfile=/home/anitha/ftptxt
echo cd mydir >>$ftpfile
echo mget '*.*' >>$ftpfile
cat $ftpfile | ftp -i server2

By the way this is unix not MSDOS. The "." is not significant in filenames though there is a convention to use it to mean filetype. Unless you want to only transfer files containing a "." in their name we would use "" rather than "*.".