Hi, I want to copy a file from Linux machine (local m/c) to Windows remote m/c. What all is required for that (eg. ssh daemon etc)? I'm able to copy file from windows to linux using jcraft (jsch). Pls help. Thanks in anticipation. Robbie
is there any other way to achieve this? there must be licensing issues with Samba and i've to copy file from linux to windows from a shell file (like i could do using jcraft)
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32765
posted
0
The JCIFS library can do this from within Java code.
Thanks Ulf. Does that mean I've to first install Samba on my Linux box and then uske JCIFS library in my java code to copy the file. What service do i need to start on remote windows machine and how do i set that?
cheers
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32765
posted
0
You don't need to install anything on either side. The only requirement is that on the Windows side the target directory must be shared, so that it's accessible over the network. But you can protect it with a username/password, so that shouldn't be a problem.
Bharat Ruparel
Ranch Hand
Joined: Jul 30, 2003
Posts: 493
posted
0
While we are on this topic. I will ask this question. I have a dual boot laptop with Windows XP Professional installed on one partition and RedHat Fedora Core 4 on another. I can access anything I want from my Windows partition while I am using Linux using auto mount. Is there something similar that I can do on the Windows side while I am working in Windows to access the Linux partition?
SCJP,SCJD,SCWCD,SCBCD,SCDJWS,SCEA
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 32765
posted
0
While we are on this topic. I will ask this question.
That's really not the same topic at all. Please do not hijack threads with unrelated questions - start a new topic.
robbie keane
Ranch Hand
Joined: Sep 05, 2005
Posts: 54
posted
0
Thanks Ulf. But how will the linux box recognise "smb://"? Can you please send the url from where i can get the code to make connection to remote windows m/c. All the examples on http://jcifs.samba.org/src/examples/ like CopyTo.java etc use arguments that will be passed into copyTo() method but none tells how will the arguments look like. I'm sure i don't have to use property file for storing remote m/c info and all that can be done in single java file. Thanks in advance. [ March 24, 2006: Message edited by: robbie keane ]
Thanks Ulf but I'm getting error while copying file. It's the CopyTo.java code (from jcisf examples)
import jcifs.smb.SmbFile; public class CopyTo { public static void main( String argv[] ) throws Exception { SmbFile from = new SmbFile( argv[0] ); SmbFile to = new SmbFile( argv[1] ); from.copyTo( to ); } } and when i run the command on linux m/c java CopyTo smb://username:loginPswd@172.19.47.101/usr/java/z.txtsmb://username:loginPswd@172.19.39.53/share/deploy I get the foll exception Exception in thread "main" jcifs.smb.SmbException: jcifs.util.transport.TransportException java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:507) at java.net.Socket.connect(Socket.java:457) at java.net.Socket.<init>(Socket.java:365) at java.net.Socket.<init>(Socket.java:178) at jcifs.smb.SmbTransport.ssn139(SmbTransport.java:178) at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:236) at jcifs.smb.SmbTransport.doConnect(SmbTransport.java:301) at jcifs.util.transport.Transport.run(Transport.java:223) at java.lang.Thread.run(Thread.java:595)
at jcifs.util.transport.Transport.run(Transport.java:239) at java.lang.Thread.run(Thread.java:595)
at jcifs.smb.SmbTransport.connect(SmbTransport.java:288) at jcifs.smb.SmbTree.treeConnect(SmbTree.java:132) at jcifs.smb.SmbFile.connect(SmbFile.java:791) at jcifs.smb.SmbFile.connect0(SmbFile.java:761) at jcifs.smb.SmbFile.copyTo(SmbFile.java:2005) at CopyTo.main(CopyTo.java:9)