Operating System - HP-UX
1827990 Members
2247 Online
109973 Solutions
New Discussion

windows to unix ftp script

 
SOLVED
Go to solution
KRS_1
Frequent Advisor

windows to unix ftp script

i need a script to automate a job from unix to windows. Any help will be appreciated

Thanks
Rajesh
5 REPLIES 5
Alan Meyer_4
Respected Contributor

Re: windows to unix ftp script

ftp -v -n <open destination_node
user username password
put filename
quit
EOF


NOTE:
This assumes that username's default directory is where you want to upoad the files. If not, insert a cd command to change directory before the put statement.
" I may not be certified, but I am certifiable... "
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: windows to unix ftp script

If you are going from a UNIX client to a Windows FTP server then you have to install and start an FTP server on Windows.

In either case, a very straightforward way of setting up a scripted FTP client is via Perl's NET::FTP Module.

You can install a free version of Perl for Windows from http://www.activeperl.com/.

Here is the ftpget.pl. You can specify the remotehost, login, password, (or read them from .netrc), directory, binary or ASCII, and filenames. Invoke as ftpget.pl -u for full usage.

Generally it's something like:
ftpget.pl -h remotehost -l cstephen -p topsecret -A -d /var/tmp -t 5 file1 file2
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "All files ok"
else
echo "Failed; status = ${STAT}"
fi

All error-checking, timeouts, and retries are built-in.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: windows to unix ftp script

And heres the clint program for put's. ftpput.pl. As before invoke with -u for full usage.
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: windows to unix ftp script

The problem with the vast majority of shell/batch file FTP programs is that absolutely no attention is paid to error checking. If the host can't be reached, if the file doesn't exist, etc., typically the scripts just blindly goes ahead and you don't have a clue that anything went wrong. With Perl's Net::FTP, you get the error-checking "for free". It's really the way to do this unless your want to implement secure shell or secure FTP and yes, there's a Perl module for secure FTP as well but for ordinary use, the Perl client scripts supplied will do very well.
If it ain't broke, I can fix that.
KRS_1
Frequent Advisor

Re: windows to unix ftp script

Thanks for your help.