*
The moose likes Linux / UNIX and the fly likes Need script to copy file on FTP server from Windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Need script to copy file on FTP server from Windows" Watch "Need script to copy file on FTP server from Windows" New topic
Author

Need script to copy file on FTP server from Windows

Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
Need script to copy file on FTP server from Windows


Set of files are on FTP server in a folder. I need a script that:

- logins to ftp server
- copy a file from one folder to another
- mget the file to windows
- then bye

I want to run this job from the windows bat file.

Thank you
Peter Rooke
Ranch Hand

Joined: Oct 21, 2004
Posts: 800

You may be best to have a look at the Expect utility. You can a windows version.


Regards Pete
Ghulam Rashid
Ranch Hand

Joined: Jan 14, 2002
Posts: 278
But, it requires to download and install 3rd Party tool.
Is there something from Window, itself?
Peter Rooke
Ranch Hand

Joined: Oct 21, 2004
Posts: 800

Don't know - problem you have is with programs that require passwords (ie ftp), is that you have to simulate keyboard entry. That is what expect does for you.

You could write it in Java.
Kevin Wright
Ranch Hand

Joined: Jul 10, 2001
Posts: 38
You can also use .netrc to store usernames and password. The rest appears easy to script using *nix tools.
Brian Wright
Greenhorn

Joined: Dec 12, 2005
Posts: 11
FTP has it's own scripting capability - check that out first, I'd suggest.
Syedz -X-
Greenhorn

Joined: Aug 13, 2006
Posts: 3
For ftp'ing files/dir from windows box you need to create two files

1) a .bat files contain everthing you need and this line

ftp -in < autoftp

2) file called autoftp with this as a content

open 192.168.1.3 <--your ip
user root abc123 <--username and passwd
verbose
type ascii
hash
cd /home/syedz <-- remote dir
pwd
lcd /root/ftp_test <-- local dir
mput *
bye


DONE!!
Vijay Vaddem
Ranch Hand

Joined: Feb 13, 2004
Posts: 243
If required, you may use ant script to do this....
This will be helpful for both windows and linux...

I was unable to copy the ant task here...
it is showing partially.... something to do with the tags...

[ August 30, 2006: Message edited by: Vijay Vaddem ]
[ August 30, 2006: Message edited by: Vijay Vaddem ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need script to copy file on FTP server from Windows
 
Similar Threads
Need help to Copy a File from Unix to Windows
network dissconnection while copy file data in database
server to server transfer
generate a text file in another server ??
how to copy a folder using a mput in ftp on unix systems