FTP Scripts

HI All

Need a help in FTP script

i need to ask the user to enter the source ftp server and password

and target ftp server and password , once it has logged in to the source server it need to go to directory and ftp to the target server

can anyone help me on this , Sample code is required

Thanks a lot

:):b:

Just wanted to be clear ,

When i run the Shell , it has to Prompt the User for host server :

echo "Please enter the host server:"
read IP
echo "Please enter the User id :"
read user
echo "Please enter the password :"
read pass
type = ''ascii''
$ftp
open $IP
quote USER $user
quote PASS $pass
$type

This wont work can anyone modify this and let me know , Thanks

Please help me on this

Use $HOME/.netrc then you ftp will do all the username/password for you.

Hi

I tried to do that ,

can you please let me know

Just explaining the scenario

i am login to the Target server and asking the Source ftp server once it login just giving the directory name and get some files from source directory , is it possible , can you please give a sample code to fix this issue

Thanks

If you are thinking of ftp automation then as suggested by porter.
This may help

Yes Thanks for the info :

But it is kind of critical in touching those files in my environment

I will post my code here , can you please let me know what went wrong here :

#!/bin/sh
echo " Please Enter the FTP Server Address :"
read FTP_SRVR
echo "Please Enter the User id :"
read FTP_USR
echo "Please enter the FTP Password :"
read FTP_PWD
ifile="/home/app/ins/seven/rem/"
ofile="/home/app/ins/six/ddf"
ftp <<EOF
open $FTP_SRVR
user $FTP_USR
pass $FTP_PWD
ascii
cd $ifile
lcd "$ofile"
mget *.*
bye
EOF

ftp -nv <<EOF

P.S. Pls DO use vB Codes when quoting code/text.

It worked , but it is asking for the password once again for the source server

any clue ?

Thanks

try:

open $FTP_SRVR
user $FTP_USR $FTP_PWD

Thanks a Lot :slight_smile:

I am working on few more conditions , hopefully i would try to complete

Is there a way to hide the Password when we are typing ?

Thanks

you can close your eyes..... :wink:

#!/bin/ksh

oldmodes=$(stty -g)
stty -echo
read password
stty ${oldmodes}

Thanks !!!

It worked fine ..

But is there a way to read from a file about the directories

for an example , the directories are not going to be constant and i am trying to get a file from a server by reading the param file a.txt

and placing it in a directory in the target which should also be read from a file

i am struggling a bit here

can anyone help me on this

Thanks

here's an idea to expand upon - it probably does not answer your specific question, but should make you think how to adopt it to what you need.

#!/bin/ksh

ftp -nv <<EOF
open $FTP_SRVR
user $FTP_USR
pass $FTP_PWD
ascii
cd $ifile
lcd "$ofile"
$(sed -e 's/^/get /g' ${listOfFiles})
bye
EOF

not sure of this function , so you mean to say that , the list of files i need ti define it in a variable , ?

before the ftp session starts

yes. the value of variable 'listOfFiles' is the pathname to the file containing the 'file names' that you need to operate on (one per line).

Just Checking whether will it work , if i give the directory there in list of files
mean to say only the directory name and getting all the files in the directory
to the remote server?

Thanks

well.... your initial explanation was not clear and I had to throw just an idea.
what exactly do you want to specify?

  1. a list of files to be transfered?
  2. a list of directories - and get/put ALL the files from 'listed' directories?
  3. maybe a combination of the above????

What I've posted covers '1.'