Operating System - HP-UX
1834914 Members
2465 Online
110071 Solutions
New Discussion

Re: ftp from UNIX to windows

 
SOLVED
Go to solution
Marcin_10
Occasional Advisor

ftp from UNIX to windows

For reporting, I would like to write script to ftp one file from Unix server to MS windows for later process. I was successful in transferring from UNIX to UNIX but with out luck to windows. I need to add this script to my night job this is way I need ftp code as part of process, anything helps

Thanks
Marcin
Marcin
18 REPLIES 18
John Poff
Honored Contributor

Re: ftp from UNIX to windows

Hi,

You probably will need an ftp service running on your Windows box so that the Unix box can ftp to it.

Another way to do it would be to setup Samba and map the directory containing the file as a share to the Windows box. Then, you wouldn't even have to move the file.

My preferred way to do it would be to replace the Windows box with a Linux box, but that solution may be too far out of the box for you.

JP
Steven E. Protter
Exalted Contributor

Re: ftp from UNIX to windows

The script will work.

You need to install the ftp service on windows. The server is not installed by default.

It can be added from the OS install cd.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Michael Schulte zur Sur
Honored Contributor

Re: ftp from UNIX to windows

Hi,

have you tried manually to ftp a file to the windows machine? Then you will see, whether there is someone to handle the request. The other thing is to schedule the ftp script on unix, which can be done by at or crontab.

greetings,

Michael
Ron Kinner
Honored Contributor

Re: ftp from UNIX to windows

If you need an FTP server for Windows, the WAR FTP Daemon is about the best around and the price is right. Free.

http://www.jgaa.com/index.php?menu=154

Ron



Hoefnix
Honored Contributor

Re: ftp from UNIX to windows

It's also possible to install Windows Services for UNIX 3.5.
http://www.microsoft.com/windows/sfu/downloads/default.asp

In the features list they say it has an NFS service in it. The you can copy file using a NFS filesystem on windws box.

Regards,

Peter
Steven E. Protter
Exalted Contributor

Re: ftp from UNIX to windows

If you have a choice between Microsoft's ftp service and anything else, go with anything else.

FTP isn't secure, Microsoft sets the standard in insecure already.

If this is a limited in house server, you might want to go with a Secure FTP server. Why do you want to transmit passwords across your network in clear text?

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Darren Prior
Honored Contributor

Re: ftp from UNIX to windows

Hi Marcin,

CIFS client could be a useful tool for you. It enables you to map a shared drive from your Windows box to your HP-UX box.

http://docs.hp.com has documentation, the actual product can be downloaded from http://software.hp.com

regards,

Darren.
Calm down. It's only ones and zeros...
Robert Kerr
Advisor

Re: ftp from UNIX to windows

I have seen something like this before, specifically mgets and wildcards did not dependably work (or dependably fail) and often hung up.

Updating the patch level on the Windows host solved the problem. What specific level, I don't recall.
Michael Schulte zur Sur
Honored Contributor

Re: ftp from UNIX to windows

Hi Marcin,

are you still with us?

Michael
Marcin_10
Occasional Advisor

Re: ftp from UNIX to windows

Sorry for not responding, I have been traveling for past few days with limited access to e-mail. I am looking only for script FTP how I pass Window password and IP, because I have to send file from UNix box to SQL server this is only one file, I do not wont to install any FTP programs on SQL servers.

Thanks for help

Marcin
Marcin
doug mielke
Respected Contributor

Re: ftp from UNIX to windows

We use CIFS for things like this. It allows mounting of the Windows filesystems, provides an authentification method, appears as local file to users, aloows instant updates when the file is cahnged on the Win side, and it's free. Once installed, we've found many uses for it.

( I've heard that the Unix compatabilty featers for Windows are now free from MSoft as well, but 'free' was what moved us to CIFS / Samba.
Michael Schulte zur Sur
Honored Contributor

Re: ftp from UNIX to windows

Hi Marcin,

in that case you may want to consider doing the ftp on the SQL Server. An ftp client should exist and you can programme it for a certain time.

Michael
Darren Prior
Honored Contributor

Re: ftp from UNIX to windows

Hi Marcin,

you could use a here document in your script. These are documented in the shell's man page I believe. This would allow you to have the username and password within the script file, but you still need to have a ftp server on the Windows box.

Here's an example you could modify:

/ftp -nv <open yourftpserver.com
user
bin
cd whatever
put somefile
quit
EOD

regards,

Darren.
Calm down. It's only ones and zeros...
A. Clay Stephenson
Acclaimed Contributor

Re: ftp from UNIX to windows

By far, the easiest method is to use Perl's Net::FTP module. It also honors the standard .netrc conventions so that no login data need be added to your scripts -- although you can use the passwd if you like. The thing I really dislike about your script is that absolutely no error checking is done. You really have no clue whether or not the file was sent. Using Perl this is trivially simple and the attached code will even retry on failure.

You can turn the world around and not even need an ftp server on the Windows side if you use one of the freely available Perl's for Windows. http://www.activestate.com/Products/Language_Distributions/

Well written Perl code would run without changes either on a UNIX or Windows host.

ftpput.pl file1 file2
STAT=${?}

would send file1 and file2 to /tmp in ASCII mode on host "remotehost" as written but you can easily adapt it to fit your needs. It will automatically attempt 5 retries before giving up. Moreover, if ${STAT} = 0 then you know all is well.
If it ain't broke, I can fix that.
Marcin_10
Occasional Advisor

Re: ftp from UNIX to windows

Thanks Darren,

This is what I was looking for, I try script you send me and it is working. Only problem I have is I try to change dir on windown box from unix, do not let me change dir or I do not know how, it asked me (remode-directory)
then I try all options like \\ip\dir or // or / I am getting not file found. any idea how to do it

Marcin
Marcin
Darren Prior
Honored Contributor
Solution

Re: ftp from UNIX to windows

Hi Marcin,

There must be a ftp server configured on your Windows box then...

As A. Clay wisely pointed out, there is no error checking in this script so you should be aware that it may appear to complete but may not have performed exactly as you expected.

Before you run this script you should try manually ftp'ing to the Windows box and using cd to move around. It's possible that you may need to specify the drive letter - I have no Windows boxes with ftp enabled so cannot be sure.

regards,

Darren.
Calm down. It's only ones and zeros...
Marcin_10
Occasional Advisor

Re: ftp from UNIX to windows

Yes Darren, I was able to ftp to Windows rest is cosmetics

thanks a lot

Marcin
Marcin
Patrick Wallek
Honored Contributor

Re: ftp from UNIX to windows

To change directories from within an FTP client you simply 'cd' to them.

cd /dir/subdir

You can also use 'dir' to see what files and directories are the directory you are currently in.