ftp with shell script

Can I ftp to put file with shell script(as bath file) ?
Plz give the simple code to do that.

My script look like that

#!/bin/sh
echo "Start ftp"
ftp temphost <<EOF
put file
quit
EOF
# end

This code ignore username & password but I need to input.
How to input username & password to this code ? Thk

edit .netrc file at your home directory ,add code like this:
machine 192.168.0.1 login myusr password 123
save it,then chmod 600 .netrc
ps:192.168.0.1 is destination address
myusr is your login name
123 is your password

or get userid/password before starting ftp (not for insecure environments as password is visible):

 
#!/bin/sh
read uid?"UserId: "
read pwd?"Password: "
echo "Start ftp"
ftp -n temphost <<EOF
user $uid $pwd
put file
quit
EOF
# end

would you mind using expect/autoexpect command?
it's a shell script isn't it?
it's really useful for interactive programs....
worth a try.....

Thks all very much for answer

Dear Friends,

Please Let me know which .netrc file should I edit either in my home directory of in the destination home directory.
I need to know the idea of .netrc file. I really misunderstand it.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Actually what I'm doing is the following:

  1. I have 192.168.30.151 unix server
  2. I have 123.123.130.200 unix destination server.
  3. I need to ftp auto. from server No. 1 to destination server.
    How can I make this in detail. please .

Sorry guys. I've understood what you have written. and I'm totally great full for your efforts and excellent ideas. thanx again and again.

Just to add the code snippet out here, this is what I've used:

USERNAME=
PASSWORD=
UTLDIR=/dbs/UTLDIR/
TMPDIR=$UTLDIR/tmp
PROCESSEDDIR=$UTLDIR/PROCESSED

# Create the FTP file.
echo "open hostname" > $File.Ftp.scr
echo "user $USERNAME $PASSWORD" >> $File.Ftp.scr
echo "bin" >> $File.Ftp.scr
echo "cd Temp" >> $File.Ftp.scr
echo "lcd $UTLDIR" >> $File.Ftp.scr
echo "put $FILE" >> $File.Ftp.scr
echo "quit" >> $File.Ftp.scr
ftp -inv < $File.Ftp.scr >> ftp.log
rm $File.Ftp.scr

Hi thestevew,
Noticed your read statements.
What's with the `?` at the end of the variable - never seen it used before (nor find reference in a 'man read').

Cheers,
Cameron