?
Solved

help required to ftp my unix files to windows machine

Posted on 2006-06-29
1
Medium Priority
?
639 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
[X]
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
1 Comment
 
LVL 5

Accepted Solution

by:
sriramiyer earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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.
Suggested Courses

743 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