Solved

help required to ftp my unix files to windows machine

Posted on 2006-06-29
1
620 Views
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
...
...
etc.

This is needed urgently.

I am a novice user in UNIX.

0
Comment
Question by:karunamoorthy
1 Comment
 
LVL 5

Accepted Solution

by:
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

and

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


script 1: UNIX TO WINDOWS
-------------------------
ls $* > ftp.lst
while read infile
do
ftp -v 80.0.0.15 >ftp.work 2>ftp.err <<!
cd winftpdirname/foldername  
put $infile
bye
!
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

script 2: WINDOWS TO UNIX
-------------------------
ftp -v 80.0.0.15  > ftp.worked 2> ftp.failed <<!
ascii    
cd winftpdirname/foldername
get $1  
bye
!

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 $$

from
SriRamIyer.


0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

772 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