How to use ftp commands inside shell script? Help please

Dears,

I'm new in shell scripting and i need your help, i would like to know how can i create a script to ftp to a certain unix/linux machine/server IP address and get a file for example without user intervention? How can i force the script to use a certain username and password to access this machine then execute the "change directory" to go to a certain path and get the requested file?

I appreaciate your help

Many thanks in advance

quote=Dendany83;302303901]Dears,

I'm new in shell scripting and i need your help, i would like to know how can i create a script to ftp to a certain unix/linux machine/server IP address and get a file for example without user intervention? How can i force the script to use a certain username and password to access this machine then execute the "change directory" to go to a certain path and get the requested file?

I appreaciate your help

Many thanks in advance
[/quote]

Your can shell as follows
shellname ftpservername userid password localdir remotedir filename

#!/bin/ksh
LANHOST=$1
USER=$2
PASSWD=$3
SRCDIR=$4
DATAIN=$5
FILENAME=$6
ftp -nv ${LANHOST} <<END
user ${USER} ${PASSWD}
cd  ${SRCDIR}
lcd ${DATAIN}
get ${FILENAME} 
bye
END

Thanks Siquadri for your propmt reply, i will try it :b:

ftp -v -n "172.21.142.108" << cmd
user "amit" "12345678"
cd /export/home/amit
lcd /export/home/voipa9/
bin
hash
get $1
quit
cmd

Yes, you CAN do the scripting as suggested above. However, if anything goes wrong, those simplistic scripts will fail unpleasantly.

Nowadays I really recommend using simple Perl scripts for this kind of task. It's not at all hard - see Perl Net::FTP for an introduction.