0

Can we ftp specific files from a directory. And these specific files that needs to be transferred will be specified in config file.

Can we use a for loop once logged into ftp (in a script) for this purpose.

Will a normal ftp work when transferring files from Unix to win ftp server.

Thanks, Ravi

Ravi
  • 7,939
  • 14
  • 40
  • 43
  • Hi Ravi, yes its possible to do this, http://www.mavetju.org/unix/netrc.php following explains how to set up a .netrc file for authentication for your FTP client, then it should be a trivial task to script the FTP actions. – David K Nov 13 '12 at 20:54
  • If we are transferring a files from machines "A" to "B". Once I login into B using ftp, will I be able to read the contents of a text file in machine 'A'? – Ravi Nov 13 '12 at 21:08

2 Answers2

0

That certainly is possible. You can transfeer files listed in some file by implementing a script using an ftp client (buildin or via calling a cli client). The protocol is system independant, therefore it is possible to transfer files between systems running different operating systems. There is only one catch: remember that MS-Windows uses a case insensitive file system, other systems differ in that.

arkascha
  • 41,620
  • 7
  • 58
  • 90
0

You can use straight shell. This assumes your login directory is /home/ravi Try this one time only:

  echo "machine serverB user ravi password ravipasswd" > /home/ravi/.netrc
  chmod 600 /home/ravi/.netrc

test that .netrc works - ftp serverB should log you straight in.

Shell script that reads config.file, which is just a list of files to send

while read fname 
do
   ftp serverB <<EOF
   get $fname
   bye
EOF         # leave the EOF  in column #1 of the script file
done < config.file

This gets file from serverB. Change get $fname to put $fname to send files from serverA to serverB

jim mcnamara
  • 16,005
  • 2
  • 34
  • 51
  • Please excuse my ignorance, but can we do the same thing what your script does by connecting just once to ServerB. Something like 1)connect to ftp server 2) loop through the files and get/put 3)close the ftp connection. – Ravi Nov 14 '12 at 16:05
  • Yes. The script automates what you are doing manually. Which is what I believed you were looking for. – jim mcnamara Nov 15 '12 at 00:12