Operating System - HP-UX
1753971 Members
8618 Online
108811 Solutions
New Discussion юеВ

ftp a file to local system

 
SOLVED
Go to solution
Muktha
Frequent Advisor

ftp a file to local system

Hi all,

Could you please give me a solution to ftp a file from a unix box to my local desktop ?
Through command prompt I am able to transfer the files.But I need to do in unix script.

Regards
Muktha
7 REPLIES 7
Aneesh Mohan
Honored Contributor

Re: ftp a file to local system


Hi Muktha,

>from a unix box to my local desktop ?

which OS is running in your desktop ,you should have ftp server configured on your laptop for doing this.


Aneesh


Dennis Handly
Acclaimed Contributor
Matti_Kurkela
Honored Contributor
Solution

Re: ftp a file to local system

When you run ftp commands from the command prompt on your desktop, you're using an FTP *client* program to contact an FTP *server* program on the unix box.

The unix box can command the FTP transfer only if there is a FTP *server* on your desktop.

Unix machines usually have both the client and the server installed, but in Windows desktops, there is usually no server, just a client. In this situation, the desktop can both "push" and "pull" files to/from the unix box, but the unix box cannot connect the desktop and start a transfer in either direction.

The Windows command-line FTP client may be scriptable using .BAT or .CMD files. But that does not belong to a HP-UX forum section...

MK
MK
Muktha
Frequent Advisor

Re: ftp a file to local system

Thanks to all.
Thank you very much Matti.
I was not aware of this.Thanks for the datailed explanation.
Now I am trying for any other method to do the same.

Could you please help me?

Regards
Muktha
OFC_EDM
Respected Contributor

Re: ftp a file to local system

Why do you have to initiate the transfer from the Unix side?..just curious. Its much easier to install FTP/SSH clients on the PC and transfer to the Unix server.

For FTP you need to download an FTP server such as FileZilla which you can find at http://filezilla-project.org/ and install on your PC.

The same can be said for SSH. An example of an SSH server is WinSSHD which you can find at http://www.bitvise.com/download-area

Do a google search and you'll find many FTP/SSH server applications out there.

Whether you run an FTP or SSH server on your PC you'll have some setup to do including setup a userid / password with which to connect. As well as specify the folder on your PC which the userid has permissions to receive files.

The SSH setup will involve generating keys to grant the unix user rights to access the SSH server running on your PC.

The SSH setup is more involved but is more secure and what I'd recommend.

Check with your IT security team and see whether running an FTP/SSH server on your PC is allowed.

For scripting using SSH I find easier. As you use the command SCP to transfer the files.

scp /path/to/file/on/UX username@pcname

This will upload a file from the UX server to the PC to the directory pre-defined for that user in the SSH server software.

Regards
The Devil is in the detail.
James R. Ferguson
Acclaimed Contributor

Re: ftp a file to local system

Hi:

If you don't want to implement a secure FTP like WinSCP:

http://winscp.net/eng/index.php

...then I could strongly consider using a 'netrc' based FTP (rather than bury passwords in scripts) or better yet, implement a SSH SFTP script using public keys.

Regards!

...JRF...
rmueller58
Valued Contributor

Re: ftp a file to local system

Get a copy of 3COM's FTP Server,
ftp://ftp.3com.com/pub/utilbin/win32/3cs117.zip

Install it, define a user and set it up as a server.


Then in your script I prefer using expect
If you have expect installed
Fill in the REALIP, username,password, directory, filename

#!/usr/local/bin/expect --
spawn ftp
expect "Login:"
send "username\r"
expect "password:"
send "password\r"
expect "ftp> "
send "prompt\r"
expect "ftp> "
send "cd destination\r"
expect "ftp> "
send "ascii\r"
expect "ftp> "
send "get filename\r"
expect "ftp> "
send "quit\r"