Remote machine file copy
Hi,
I am looking out for a code to copy a file to a remote server which does not support http but i have access to it.
My requirement is to do this using a core java code at only the client side.
Any help would be greatly appreciated
I'm not sure that correctly understand your task. IMO your questions should be in java forum.
Assume you have a ftp access to server. Then you can look at java ftp support libaries or simply invoke external ftp client to copy file. See http://forums.sun.com/thread.jspa?threadID=5395532.
Similar Messages
-
Any suggestions?
However, I can use scp to copy files out from my iMac (10.6.8) .
I can ssh into the iMac OK.
I created a .profile in my iMac home directory with the single line "export TERM=xterm-color".
This makes a difference to how scp behaves when attempting to copy into the iMac, but it still fails.
Thanks in advance for any help. Peter R
Here is the scp debug output (on the remote machine that I'm copying a file from, to the iMac):
===
Executing: program /usr/bin/ssh host molika.ucsd.edu, user prowat, command scp -v -t Desktop/FromPelican/Outs201201.pdf
Sun_SSH_1.1.3, SSH protocols 1.5/2.0, OpenSSL 0x0090704f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to molika.ucsd.edu [137.110.243.133] port 22.
debug1: Connection established.
debug1: identity file /home/nona/.ssh/identity type -1
debug1: identity file /home/nona/.ssh/id_rsa type -1
debug1: identity file /home/nona/.ssh/id_dsa type -1
debug1: Remote protocol version 1.99, remote software version OpenSSH_5.2
debug1: match: OpenSSH_5.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-Sun_SSH_1.1.3
debug1: use_engine is 'yes'
debug1: pkcs11 engine initialized, now setting it as default for RSA, DSA, and symmetric ciphers
debug1: pkcs11 engine initialization complete
debug1: Failed to acquire GSS-API credentials for any mechanisms (No credentials were supplied, or the credentials were unavailable or inaccessible
Unknown code 0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: Peer sent proposed langtags, ctos:
debug1: Peer sent proposed langtags, stoc:
debug1: We proposed langtags, ctos: i-default
debug1: We proposed langtags, stoc: i-default
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: dh_gen_key: priv key bits set: 124/256
debug1: bits set: 1007/2048
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'molika.ucsd.edu' is known and matches the RSA host key.
debug1: Found key in /home/nona/.ssh/known_hosts:1
debug1: bits set: 1043/2048
debug1: ssh_rsa_verify: signature correct
debug1: newkeys: mode 1
debug1: set_newkeys: setting new keys for 'out' mode
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: newkeys: mode 0
debug1: set_newkeys: setting new keys for 'in' mode
debug1: SSH2_MSG_NEWKEYS received
debug1: done: ssh_kex2.
debug1: send SSH2_MSG_SERVICE_REQUEST
debug1: got SSH2_MSG_SERVICE_ACCEPT
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/nona/.ssh/identity
debug1: Trying private key: /home/nona/.ssh/id_rsa
debug1: Trying private key: /home/nona/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
*** Password requested & supplied
debug1: Authentication succeeded (keyboard-interactive)
debug1: fd 5 setting O_NONBLOCK
debug1: fd 6 setting O_NONBLOCK
debug1: fd 7 setting O_NONBLOCK
debug1: channel 0: new [client-session]
debug1: send channel open 0
debug1: Entering interactive session.
debug1: ssh_session2_setup: id 0
debug1: channel request 0: env
debug1: Sending command: scp -v -t Desktop/FromPelican/Outs201201.pdf
debug1: channel request 0: exec
debug1: channel 0: open confirm rwindow 0 rmax 32768
~
debug1: channel 0: read<=0 rfd 5 len 0
debug1: channel 0: read failed
debug1: channel 0: close_read
debug1: channel 0: input open -> drain
debug1: channel 0: ibuf empty
debug1: channel 0: send eof
debug1: channel 0: input drain -> closed
debug1: channel 0: write failed
debug1: channel 0: close_write
debug1: channel 0: output open -> closed
debug1: channel 0: rcvd eof
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: rcvd close
debug1: channel 0: almost dead
debug1: channel 0: gc: notify user
debug1: channel 0: gc: user detached
debug1: channel 0: send close
debug1: channel 0: is dead
debug1: channel 0: garbage collecting
debug1: channel_free: channel 0: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 1 clearing O_NONBLOCK
debug1: fd 2 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 0.9 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0On looking at the secure.log on the iMac with OSX10.6.8, I see these entries at each attempt to scp into the iMac:
Dec 29 11:06:20 molika sshd[7248]: in pam_sm_authenticate(): Failed to determine Kerberos principal name.
Dec 29 11:06:26 molika sshd[7246]: Accepted keyboard-interactive/pam for prowat from 137.110.243.132 port 35571 ssh2
Dec 29 11:06:26 molika com.apple.SecurityServer[26]: Session 0x236a14 created
Dec 29 11:06:26 molika com.apple.SecurityServer[26]: Session 0x236a14 attributes 0x20
Dec 29 11:06:27 molika com.apple.SecurityServer[26]: Session 0x236a14 dead
Dec 29 11:06:27 molika com.apple.SecurityServer[26]: Killing auth hosts
Dec 29 11:06:27 molika com.apple.SecurityServer[26]: Session 0x236a14 destroyed
I don't know what to make of this.
Peter R -
Aloha:
I am newbie to servlet programming:
I am trying to send a file from one machine (A) to another machine(B) and both the systems have webservers running on them. Once B recieves the file the result needs to be sent back to A. How can i accomplish this using web servers. I don't have permission to FTP RCP etc on either machines.
Can someone help me here??
TIA
FSKCheck out multipart form uploads.
There are loads of classes that can do this.
servlet a simply http uploads the file to b).
b) runs some check on the file to ensure it is valid, then calls a servlet back on a) to say its ok.
Look on the apache.org site for the commons upload class. -
Show browse files dialog by listing remote machin files in web application
Hi all,
I want to develop a web application which has "Browse Server" button to browse remote server. After selecting files and folders from remote server, need to read all files and folders from server and store that information in Database. Please provide some ideas and help regarding this.
I think that i need to develop a custom component based on jfilechooser to connect to server and show the selection dialog like windows file upload.
I don't no how to list server files and show as browse dialog to select and read those files.
Thanks in advance.
Regards,
Venkata Subba ReddyMost web browsers can browse FTP. You can achieve what you want without writing a single line of code. How cool is that?
-
Copying Files From a Remote Machine through "rcp" command not working.
Hi All,
I'm a new comer to this famous forum. I was trying to go through the PDF "Solaris Advanced User's Guide" .So in chapter 9-"Using the network" i came across "Copying Files From a Remote Machine". And the syntax was "rcp machinename:source destination" . And i got another note. It is like
"The rcp command enables you to copy files from one machine to another. This command uses the remote machine's /etc/hosts.equiv and /etc/passwd files to determine whether you have unchallenged access privileges. The syntax for rcp is similar to the command syntax for cp.".
But i maintained remote machine's IP address in my system's /etc/hosts file. But still i am unable to do the rcp from remote system to my system or vice versa.
Always i am getting error message " **Connection refused**".
Therefore please some one guide me how to perform the " Copying Files From a Remote Machine" through rcp command.
Reghards
KartikHi
The inconvenience of using scp is that you have to type the password every time you stablish a connection. You can work around this, adding a key into the remote hosts_allow file. This implies in more maintenance.
From the rcp man page:
+rcp does not prompt for passwords. It either uses Kerberos authentication which is enabled through command-line options or your current local user name must exist on hostname and allow remote command execution by rsh(1).+
From the rsh man page:
+ If you omit command, instead of executing a single command, rsh logs you in on the remote host using rlogin(1).+
By default, rlogin is disabled on Solaris 10
[SunOS 5.10/bash] root@wgtsinf01:/store/sun/operating-systems
# svcs -a|grep -i rlog
disabled May_11 svc:/network/login:rloginSo, to use rcp you have to enable the rlogin service and set up all the configuration files. Particularly, as already suggested, I too suggest you to use scp. :)
Cheers
-- Andreas
Edited by: Bank_Of_New_Zealand on 15/06/2009 13:09 -
How to read file from remote machine
Hello,
Hi, i would like to know how to read text file from remote machine using java source code, any code ?
Thanks very much;
Best regards
KimOn the server, perform the following steps:
Parse the request and determine the file to serve
Open a FileInputStream to the appropriate file
Obtain a reference to the Servlet OutputStream
Pipe the bytes from the file to the output stream
Flush and close the streamYou might want to call HttpServletResponse.setContentType("application/octet") to indicate to the browser that a file download will be occurring. Do so before getting the reference to the Servlet's OutputStream.
- Saish -
My personal Macbook pro died, but I did have a Time Machine backup. I have a new iMac that I would like to use as a family computer. I would like to transfer some files to the new computer (and set-up a new Time Machine backup), but archive the remainder on a non-TM drive. I was planning to:
1. File copy my last backup folder from my old TM drive to the new computer
2. Copy (and then delete) the files I want to archive on another HD drive
3. Wipe clean my current TM drive
4. Set-up TM on my new computer
Is this a good way to proceed?
Is copying the last backup folder (vs. all backup folders) enough to move my files over?
Any better approaches appreciated!I suggest you visit MicroCenter and go to there Apple section and ask one of there guys if they are still offering the 2 terabyte Backup For the iMac, Mine was only $100.00.
So the iMac has Time machine plus the USB 2 Terabyte Backup for less than your $130.00 -
Creating Error log files using UTL_FILE package on a remote machine
Database Version: 10g Release2
OS Platform: Sun Solaris
I have been asked to log errors to OS files rather than tables. So, i wanted to use UTL_FILE package. But the client doesn't want to store these files on the same server where the database is running(as specified in UTL_FILE_DIR). Is there a way i could get these files created on a remote machine(client).I believe what others are suggesting is that your stored procedure continues to log to a table and a separate process be created that runs on the machine you want the file to be created on which reads the log table and writes to a log file.
If that is not an option, can you expose the directory on the remote machine you want to write the file to as a file share that can be mounted by the database server? If you can, you could write errors there using UTL_FILE. However, it would probably be a bad idea. If you're logging an error already, that implies that something has gone wrong. Making an error logging process dependent on a remote server being available and properly mounted with appropriate privileges at the instant the error occurs just creates more sources of failure that would prevent you from logging an error, which would prevent you from being able to debug the problem or even know it existed without a report from a user.
Justin -
Program to open file in remote machine
Hi,
i want to write a program in which i can access a file in another system.
But the catch here is that the other system is using password to login to the system.
How i can provide password through my Java Program to access to other machine
~AmanCan you just send me the code how to read file from Shared folder/drive through java program?
e.g ="\\mcno-pc180\shared\HelloWorld.txt". I am able to access file HelloWorld.txt from my machine which is placed in shared folder path "\\mcno-pc180\shared\".
Regards
SPulluri
Share the folder/drive which you want to access on the remote machine then your application can access it.
Try to use the user which has already rights of reading/writing to that machine then the security dialog will not appear. -
How to read and writre file into remote machine in the network
HI Experts,
i want to write the data and read data into file in remote machine(not in application server and presentation server).is it possible in abap.
thanks in advance
With Regads
NaiduHi naidu,
1. We can use this type of path
computername
folder
file.ext
2. We can use this in GUI_UPLOAD
and it will run on presentation server,
connect to
computer
and read the file contents.
regards,
amit m. -
How to create a file on a remote machine using PrintStream
I want to create an HTML file on a remote machine connect via LAN the path is "\\vineet\akh\" akh is folder where I want to save the HTML file. Now in PrintStream i can give only a local file. Please help how to do it
.. You can do this in two ways!!
1) easy way
2) hard way
1) EASY WAY
.. as you know for write to a remote dir you must
a) have shared remote dir
b) have write permit on remote dir
if you have point a) and b) the way to follow it's simple as the other user explained to you!!
2) HARD WAY
the hard way is to use RMI (Remote Method Invokation)
i mean to create a service on a remote machine that give to you a remote method that make you write without share anything..!!!
check it out
http://tns-www.lcs.mit.edu/manuals/java-api-1.1beta2/guide/rmi/
i hope i'm been clear!!
SORRy My english!! (please)
Alessandro -
Accessing a XML file located in a remote machine.
I have a XML file located in a remote machine(source machine), and I want to be able to move the data from that file to a remote database (target).
I have a central ODI deployment and a central master and worker repository.
The issue I have is that it seams to me that in order to use an XML file the XML file needs to be local to the ODI client(topology manager, designer etc).
The question what do I need to do in order to access the file located in the remote source machine if that machine does not have an ODI client?
ThanksHi Terence,
why don't you try to put all your JPA stuff (classes, persistence.xml, etc) in a "library" jar file and then deploy it inside your .war (under META-INF/lib) and .ear (under the lib)?
Is it acceptable for your purpose?
Fabio De Santi -
Transfer of file to a shared folder on remote machine
Hi,
I want to transfer a file present on windows machine A to a shared folder (\\16.192.54.56\Test) on machine B having ip as 16.192.54.56, using java.
I tried using the renameTo api of File class but its not helping. It gives permission denied exception. I am able to open the shared folder from machine A using the shared folder path (\\16.192.54.56\Test) through the run command. So, that means there is no permission issue on the shared folder.
Could anybody please guide me as to how can i resolve this issue.
~BrijHi,
Please pardon me for not providing the complete information.
I have kind of root caused the issue. Let me explain the issue in detail.
I have a logic to move a file to a shared folder on remote machine, inside my application running on a different machine. Now when i run my application using
command prompt, the logic of moving the file to the shared folder works fine.
try
File fDest = new File(""\\\\15.154.52.100\\TestDir\\test");
File fSrc = File.createTempFile("testExport", "txt");
final int BUFFER = 2048;
InputStream in = new FileInputStream(fSrc);
OutputStream out = new FileOutputStream(fDest);
// Transfer bytes from in to out
byte[] buf = new byte[BUFFER];
int len;
while ( (len = in.read(buf)) > 0)
out.write(buf, 0, len);
in.close();
out.close();
fSrc.delete())
catch (Exception ex)
ex.printStackTrace();
{code}
But when i run my application as a windows service, the logic does not work.
I noticed that when we run our application as windows service, the owner of JVM is System and it looks like it will not have Network access permission.
But, when we run our application through command prompt or as a standalone application, then the owner will be the user who started the application. This user will have the Network access permission.
Please correct me if the above assumption is correct. If this is the case then how can i make my application (running as windows service), to have network access permission.
~Brij -
Getting absolute path of a file running in remote machine
Hi,
I want to get the absolute path of a file that will be created in the remote server. Inside a directory XYZ in remote machine, the file will be created and the remote machine's address is xxx.xx.x.x. I have used the following snippet
File f=new File(Filename);
f.getAbsolutePath();
Now, in the output am getting the absolute path of the file as d:/XYZ/Filename. Is there any way to get the output as xxx.xx.x.x/XYZ/FileName ? Can someone please suggest why the server details are not fetched and instead the directory name is fetched.
I am running the program to get absolute path of a file in my remote machine. and for accessing that remote file from my machine, I use xxx.xx.x.x/XYZ/FileName.
Thanks in advance.I'm going to take it a step further and guess at what the OP is going to say next.
On host w.x.y.z there's a file /a/b/share/some_dir/file.txt.
Host w.x.y.z is sharing the /a/b/share/ directory as SHARE.
Client mounts \\w.x.y.z\SHARE as D:, so that he sees D:/some_dir/file.txt.
OP now wants to know not just that D:/some_dir/file.txt is \\w.x.y.z\SHARE/some_dir/file.txt, but also wants to know that on w.x.y.z, SHARE corresponds to /a/b/share.
@OP: If that's what you want, forget it. Part of the premise of file common drive/directory sharing protocols is that the client does not know or care and does not need to know or care what the absolute path is on the serving host. It's none of his business. -
How do I copy by time machine files to another external HD?
I would like to copy the data I have in my time machine to another external HD so that I have two backups; one I can store offsight and one I can have connected to my computer. Can this be done and if so, how does one do it?
My time machine has files going back to May 2011 and contains over 500GB; my computer has only 320GB capacity. I would like to set up another external HD with the time Machine files on it so that I can use both backups alternately storing one off site and one connected to my computer. After a couple weeks then alternate them so I always a backup offsite; thus having two HD containing my time machine files.
Maybe you are looking for
-
Errors in log files; Condition: INFINITE == dwTimeout failed in file
Hi, We recently upgraded to 7.1.04 SP04 (7.1.04.129) from 7.1.03 and that's when the log entries below started appearing. I'm seeing 7 of these messages getting logged every 20 seconds in the MDS log. Stopping the MDM Syndication Server (MDSS) stops
-
I'm extremely frustrated right now. The contacts on my Z10 have been messed up and no matter what I do to try to fix them, nothing works. Contacts are going missing, they are being merged with other contacts, their names are inexplicably changing and
-
Hello, I'm configuring a WLP cluster to use a Oracle 10g RAC instance. [url http://e-generation.beasys.com/wlp/docs92/db/oracle.html]This document seems like a very good starting point. My question is: the document only specifies using Oracle Thin dr
-
I have a mac i have Acrobat 9 Pro now says I need to license it.
I have license but won't let me.
-
I installed the Companion CD and Apache server is also installed but I cannot find the HTTP service. That step says it completed successfully. Tried to go to localhost:7777 and it cannot be found. Any ideas. The Windows guy says he disabled IIS but I