Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

help required to ftp my unix files to windows machine

Posted on 2006-06-29
Last Modified: 2010-04-21
I am woking in both the UNIX and Windows environments.
I need to ftp files quite often from UNIX to WINSOWS and vice versa.

I need a script to automate the process using a UNIX shell script so that the files should go to Windows machine automatically.

like in shell prompt
myftp *.TXT
myftp *.CBL

This is needed urgently.

I am a novice user in UNIX.

Question by:karunamoorthy
1 Comment

Accepted Solution

sriramiyer earned 500 total points
ID: 17008225
Hello Karunamoorthy,

The following scripts may used for transferring files from UNIX to WINDOWS and from WINDOWS to UNIX
Here you have to replace the actual ip address of your unix machine.
and in cd the command you have to replace your windows virtual FTP directory name with the path.

and using a .netrc file. The ftp man page documents the format of .netrc. To accomplish the task of using ftp in a shell script you would have to fill out a .netrc file something like this:

machine something.else.com
login myid
password mypassword


ftp demands that .netrc not have group or world read or write permissions i.e.
PS the rights on .netrc MUST be 0600 and it must be owned by the user running the FTP command and exist in their home directory

ls $* > ftp.lst
while read infile
ftp -v >ftp.work 2>ftp.err <<!
cd winftpdirname/foldername  
put $infile
grep "226" ftp.work|awk -v fname="$infile" '{ print "File : ",fname,$2,$3}' |tee $$
[ ! -s $$ ] && cat ftp.err && rm ftp.work ftp.err $$ && exit 1 || rm ftp.work ftp.err $$
done < ftp.lst
echo "\nTotal Files transfered = `wc ftp.lst| awk '{print $1}'` "

rm ftp.lst

ftp -v  > ftp.worked 2> ftp.failed <<!
cd winftpdirname/foldername
get $1  

grep "226" ftp.worked|awk -v fname=$1 '{print "File : ",fname,$2,$3}'|tee $$

[ ! -s $$ ] && cat ftp.failed && echo "error ..." && rm ftp.worked ftp.failed $$ && exit 1 || rm ftp.worked ftp.failed $$



Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

838 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question