How to connect server using FTP
hi all,
i have an exception while running this program.
import java.io.*;
import java.net.*;
class FTPclientConn {
public final String host;
public final String user;
protected final String password;
protected URLConnection urlc;
public FTPclientConn(String host, String user, String _password) {
host= host; user= user; password= _password;
urlc = null;
protected URL makeURL(String targetfile) throws MalformedURLException {
if (user== null)
return new URL("ftp://"+ host+ "/"+ targetfile+ ";type=i");
else
return new URL("ftp://"+ user+ ":"+ password+ "@"+ host+ "/"+ targetfile+ ";type=i");
protected InputStream openDownloadStream(String targetfile) throws Exception {
URL url= makeURL(targetfile);
urlc = url.openConnection();
InputStream is = urlc.getInputStream();
return is;
protected OutputStream openUploadStream(String targetfile) throws Exception {
URL url= makeURL(targetfile);
urlc = url.openConnection();
OutputStream os = urlc.getOutputStream();
return os;
protected void close() {
urlc= null;
public class FTPupload {
protected FTPclientConn cconn;
public final String localfile;
public final String targetfile;
public FTPupload(String host, String user, String _password,
String localfile, String targetfile) {
cconn= new FTPclientConn(_host, user, password);
localfile= _localfile;
targetfile= _targetfile;
doit();
public FTPupload(String host, String user, String password, String file) {
cconn= new FTPclientConn(_host, user, password);
localfile= _file;
targetfile= _file;
doit();
protected void doit() {
try {
OutputStream os= cconn.openUploadStream(targetfile);
FileInputStream is= new FileInputStream(localfile);
byte[] buf= new byte[16384];
int c;
while (true) {
//System.out.print(".");
c= is.read(buf);
if (c<= 0) break;
//System.out.print("[");
os.write(buf, 0, c);
//System.out.print("]");
os.close();
is.close();
cconn.close(); // section 3.2.5 of RFC1738
} catch (Exception E) {
System.err.println(E.getMessage());
E.printStackTrace();
public static void main(String args[]) {
// Usage: FTPupload host, user, password, file
new FTPupload(args[0], args[1], args[2], args[3]);
i gave the input in command prompt: java FTPupload 172.16.2.1 username password filename and also i am getting exception as
D:\ftp>java FTPupload 172.16.2.1 hariraj raj_123 ftpcheck.java
Connection refused: connect
java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
how to resolve this problem.thanks in advance.
Connection refused means that you can't reach the server or that the server isn't listening.
Kaj
Similar Messages
-
How to connect server using naming service IOR and server IOR in java
I need to connect server code from my client code using naming service IOR and server IOR. what are the steps have to be followed to bind the server.
please help me.Connection refused means that you can't reach the server or that the server isn't listening.
Kaj -
How can I create a directory on my server using FTP in applescript?
Hi
I have created a script which successfully uploads files to my server using FTP and a curl command.
The one thing I haven't worked out how to do is how to create a directory on my server using applescript. At the moment I have to manually create the correct directory for the script to work, but would like to be able to automate everything.
Would this be possible?
Thanks
NickThanks Bernard.
I have tried that and still get the error message:
"curl: Can't open '--ftp-create-dirs'!
curl: try 'curl --help' or 'curl --manual' for more information
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
curl: (9) Server denied you to change to the given directory"
The other relevant parts of the script are:
set ftp_url to "ftp.****.org.uk/artists/" & artistName2 & "/assets/"
set ftp_username to "*****@*****.org.uk"
set ftp_password to "****"
set ftp_entire to ftp_username & ":" & ftp_password & " ftp://" & ftp_url
set outPath to outputFolder & fileCounter & ".jpg"
and then...
do shell script ("curl -T --ftp-create-dirs " & outPath & " -u " & ftp_entire)
Like I said, all works fine when the directories are already in place. I have permissions for the artists folder set to "777", i.e. writable. Because the script is trying to create two directories at once, i.e. "artistName2" and then "assets" under it, I wondered if this was significant, but then I tried with just one new directory, and still got the error. -
I am evauating wether to purchase Dreamweaver CS6...
Dreamweaver CS6 trial (on Windows 7) wont connect to IIS (v7) Server using "FTP over SSL/TLS (explicit encryption)". I have a NEW Godaddy SSL certificate installed on the IIS server.
On connecting Dreamweaver states: "Server Certificate has expired or contains invalid data"
I have tried:
-ALL the Dreamweaver Server setup options
-Using multiple certificates (tried 2048 bit and 4096 bit Godaddy SSL certificates)
-Made sure the certificate 'issued to' domain name matches my domain name.
I am able to connect no problem using Filezilla, with equivalent Filezilla setting "Require explicit FTP over TLS". I can also connect fine using Microsoft Expression web.Thanks for your prompt reply.
My comments:
1) You should update your tread (forums.adobe.com/thread/889530) to reflect that it still occurs on CS6 (I had already read it but figured it was an old tread and thus should be fixed by now).
2) You said “These warnings will also pop up for your users if you have a store saying the SSL certificate does not match the domain/ip and this can make users checking out in a storefront very nervous” . This does not seem to be correct – my https pages display properly using the same Godaddy certificate … using IE:
3) Godaddy is not my host (I use Amazon AWS) – but the SSL certificate is from them. -
How to call serlvet using ftp protocal
Hai,
How to call servlet using ftp protocal . if any one having please send that program . because generic servlet will receive any protocal request .The basics are to have your Server listen to port 21.
You would then have to parse the request information to determine what is being asked for and generate an appropriate response. -
How to connect peoplesoft using bapi?
how to connect peoplesoft using bapi?
points will be awardedHi,
You can actually connect any 2 systems, if they are capable of providing and consuming web services.
If you want to connect SAP to Peoplesoft to fetch or send data, then Peoplesoft should expose these functionalities in the form of Webservice. Then you will have to create Proxy Objects in SAP by consuming these webservices (SE80). Through this proxy object you can communicate with Peoplesoft.
Thanks...
Preetham S
Message was edited by:
Preetham S -
How to connect to a FTP server using a proxy in a DMZ with XI file adapter?
Hello,
Want to connect to an ftp server using a proxy in the DMZ. I don't see any standard options in the XI file adapter to use a standard. Is there a workaround?
I already looked at https://www.sdn.sap.com/irj/sdn/wiki?path=/pages/viewpage.action?pageId=57137
But it didn't help me.
Regards,
Erik van LisdonkU can't use FTP over SSH i.e., SFTP. But u may use FTPS by enabling the SSL layer on J2EE of XI. See this
SFTP vs. FTPS in SAP PI
Regards,
Prateek -
How to connect to an FTP server via Midnight Commander _User_Menu_?
Hi everyone.
There's a nifty command that works in MC and makes it connect to an FTP server and display its directories just as if they were local ones: cd ftp://USER_LOGIN@SERVER_NAME. The only thing it asks for is a password, obviously. That's exactly what i'm looking for, theoretically.
I know it's not really a standard Bash command, because if invoked outside MC, it returns an error (directory not found).
I got kind of tired of typing it in (or copypasting it) every time, so i thought why not make it automatic? A Bash alias or a shell script wouldn't work, because as i said, it's not really a bash command.
But what surprised me was that it didn't work as an entry in MC's menu, too.
Tried to go another way, discovered kftp, apparently it's completely not what i am looking for.
And i didn't even understand what F9 > Left > FTP Link in MC did. It isn't automatic as well anyway, i have to type everything in manually.
Can anyone advise how to automate FTP connection in MC, or even in Bash (so that MC just treats it like a regular directory)?
Big thanks in advance.
Last edited by kiruch (2010-07-04 20:53:44)kiruch wrote:mcsilva, here are the contents of my ~/.netrc file: machine ftp.0fees.net login MYLOGIN password MYPWD
When i invoke cd ftp://ftp.0fees.net, it tells me bash: cd: ftp://ftp.0fees.net: No such file or directory
This is not the correct way. You are using bash command line. For this to work it must be:
# mc cd ftp://ftp.0fees.net
kiruch wrote:When i invoke it as an entry of MC's menu (what i'm aiming for), i get /tmp/mc-cyril/mcusr6BWdYd: line 2: cd: ftp://ftp.0fees.net: No such file or directory - well, basically the same.
I don't know what do you mean by "invoke an entry of MC's menu",
Is this:
Left->FTP link or Right->FTP link ?
kiruch wrote:And finally, if i type cd ftp://ftp.0fees.net manually into MC's command prompt, i get a red alert message that says Cannot chdir to "ftp://ftp.0fees.net". Input/output error (5)
In the first post you said you were able to login with "cd ftp://USER_LOGIN@SERVER_NAME", so MC is working well.
This error you showed is the same which I have when I type "cd ftp.0fees.net" in the MC command prompt (maybe you typed wrong...)
Instead, when I try "cd ftp://ftp.0fees.net" the popup error is: "ftpfs: Login incorrect for user anonymous"
This is what I expected, because I don't have the username and password and I'm trying a anonymous login.
Are you sure your typing is right? Please, check your typing and try again. -
Failure to connect to FTP server using FTP Adapter?
Attempting to setup a SOA 11g composite app to demo the use of a FTP Adapter. Composite used a File Adapter (Read, opaque schema) wired to a mediator which was wired to a FTPAdapter (ASCII-Put, opaque schema). The routing rule in the mediator maps the File-Read opaque schema to the FTP ASCII-Put opaque schema.
In the document "+User's Guide for Technology Adapters 11g Release 1 (11.1.1)+" I followed the steps in 4.2.21 Securing Enterprise Information System Credentials to set username/password (ftpuser/oracle) for the eis/Ftp/FtpAdapter connection. This is the default JNDI name for the FTP Adapter.
For the FTP server installed Filezilla server. Configured the home directory to appropriate folder.
Installed Filezilla client to test the server using ftpuser/oracle - as the created user on the server. No problem here – can see the appropriate folders and ftp files to/from the folders.
Used a similar composite using a File Adapter-Write (opaque schema) instead of the FTPAdapter (ASCII-Put - opaque schema). This composite works with no issues. FYI – using JDev 11.1.1.1, SOA Suite 11g.
Was not using VPN.
When placed the required file in its directory (for the File-Read) it was read but the ASCII-Put file from Filezilla server did not appear.
Based on error/fault messages seems to be a login issue. However, have no idea as to where the issue as all usernames/passwords are correct. But then - isn't that always the case?
After having worked on this for a couple of days - need some help - please.
The following error messages appeared:
Filezilla Server:
+(000004)11/3/2010 14:06:54 PM - (not logged in) (127.0.0.1)> Connected, sending welcome message...+
+(000004)11/3/2010 14:06:54 PM - (not logged in) (127.0.0.1)> 220-FileZilla Server version 0.9.37 beta+
+(000004)11/3/2010 14:06:54 PM - (not logged in) (127.0.0.1)> 220-written by Tim Kosse ([email protected])+
+(000004)11/3/2010 14:06:54 PM - (not logged in) (127.0.0.1)> 220 Please visit http://sourceforge.net/projects/filezilla/+
+(000004)11/3/2010 14:06:54 PM - (not logged in) (127.0.0.1)> USER+
+(000004)11/3/2010 14:06:54 PM - (not logged in) (127.0.0.1)> 501 Syntax error+
+(000004)11/3/2010 14:07:53 PM - (not logged in) (127.0.0.1)> disconnected.+
Fault message from WLS enterprise manager for the composite
onMessage
Nov 3, 2010 2:06:54 PMonCase "FTPPut.Put"
Nov 3, 2010 2:06:54 PMTransformed message part "opaque" using "xsl/opaqueElement_To_opaqueElement_3.xsl"
Nov 3, 2010 2:06:54 PMError during invoking 1-way operation "Put" on target service "FTPPut"
Exception occured when binding was invoked. Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Put' failed due to: Error in logging in. Error in logging in. Unable to log in to the server. ". The invoked JCA adapter raised a resource exception. Please examine the above error message carefully to determine a resolution.
Output from SOA Server console window
Nov 3, 2010 2:06:54 PM oracle.integration.platform.blocks.adapter.fw.log.LogManagerImpl log
SEVERE: JCABinding=> FileR FileRAdapter Service FileR was unable to perform delivery of inbound message to the composite default/Project1!1
+.0*03f979cb-4a66-4c89-8a68-cce43fcdef88 due to: BINDING.JCA-12563+
Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Put' failed due to: Error in logging in.
Error in logging in.
Unable to log in to the server.
+".+
+The invoked JCA adapter raised a resource exception.+
+Please examine the above error message carefully to determine a resolution.+
+Nov 3, 2010 2:06:54 PM oracle.integration.platform.blocks.adapter.fw.log.LogManagerImpl log+
+WARNING: File Adapter Project1 InboundTranslatorDelegate caught Generic Exception , the Resource Adapter will ignore this+
+Nov 3, 2010 2:06:54 PM oracle.integration.platform.blocks.adapter.fw.log.LogManagerImpl log+
+WARNING: File Adapter Project1+
+BINDING.JCA-12509+
+Unable to post inbound message.+
+Unable to post inbound message to Composite.+
+The JCA Listener of the JCA Binding Component was unsuccessful in delivering an inbound message from the endpoint FileR due to the following+
+reason: oracle.fabric.common.FabricInvocationException: BINDING.JCA-12563+
+Exception occured when binding was invoked.+
+Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Put' failed due to: Error in logging in.+
Error in logging in.
Unable to log in to the server.
+".+
+The invoked JCA adapter raised a resource exception.+
+Please examine the above error message carefully to determine a resolution.+
+Please examine the log file for any reasons. Make sure the inbound XML messages sent by the Resource Adapter comply to the XML schema defini+
+tion of the corresponding inbound WSDL message element.+
+at oracle.integration.platform.blocks.adapter.fw.jca.mdb.AdapterServiceMDB.onMessage(AdapterServiceMDB.java:552)+
+at oracle.integration.platform.blocks.adapter.fw.jca.messageinflow.MessageEndpointImpl.onMessage(MessageEndpointImpl.java:376)+
+at oracle.tip.adapter.file.inbound.Publisher.publishMessage(Publisher.java:377)+
+at oracle.tip.adapter.file.inbound.InboundTranslatorDelegate.xlate(InboundTranslatorDelegate.java:455)+
+at oracle.tip.adapter.file.inbound.InboundTranslatorDelegate.doXlate(InboundTranslatorDelegate.java:116)+
+at oracle.tip.adapter.file.inbound.ProcessorDelegate.doXlate(ProcessorDelegate.java:252)+
+at oracle.tip.adapter.file.inbound.ProcessorDelegate.process(ProcessorDelegate.java:157)+
+at oracle.tip.adapter.file.inbound.ProcessWork.run(ProcessWork.java:349)+
+at oracle.integration.platform.blocks.executor.WorkManagerExecutor$1.run(WorkManagerExecutor.java:77)+
+at weblogic.work.j2ee.J2EEWorkManager$WorkWithListener.run(J2EEWorkManager.java:171)+
+at java.lang.Thread.run(Thread.java:619)+
+Caused by: oracle.fabric.common.FabricInvocationException: BINDING.JCA-12563+
+Exception occured when binding was invoked.+
+Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Put' failed due to: Error in logging in.+
Error in logging in.
Unable to log in to the server.
+".+
+The invoked JCA adapter raised a resource exception.+
+Please examine the above error message carefully to determine a resolution.+
+at oracle.integration.platform.blocks.adapter.fw.jca.cci.EndpointInteractionException.getFabricInvocationException(EndpointInteracti+
+onException.java:75)+
+at oracle.integration.platform.blocks.adapter.AdapterReference.getFabricInvocationException(AdapterReference.java:294)+
+at oracle.integration.platform.blocks.adapter.AdapterReference.post(AdapterReference.java:281)+
+at oracle.integration.platform.blocks.mesh.AsynchronousMessageHandler.doPost(AsynchronousMessageHandler.java:142)+
+at oracle.integration.platform.blocks.mesh.MessageRouter.post(MessageRouter.java:194)+
+at oracle.integration.platform.blocks.mesh.MeshImpl.post(MeshImpl.java:204)+
+at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)+
+at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)+
+at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)+
+at java.lang.reflect.Method.invoke(Method.java:597)+
+at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)+
+at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)+
+at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)+
+at oracle.integration.platform.metrics.PhaseEventAspect.invoke(PhaseEventAspect.java:71)+
+at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)+
+at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)+
+at $Proxy195.post(Unknown Source)+
+at oracle.tip.mediator.serviceEngine.MediatorServiceEngine.post2Mesh(MediatorServiceEngine.java:870)+
+at oracle.tip.mediator.service.BaseActionHandler.requestProcess(BaseActionHandler.java:200)+
+at oracle.tip.mediator.service.BaseActionHandler.requestProcess(BaseActionHandler.java:94)+
+at oracle.tip.mediator.service.BaseActionHandler.requestProcess(BaseActionHandler.java:74)+
+at oracle.tip.mediator.service.OneWayActionHandler.process(OneWayActionHandler.java:47)+
+at oracle.tip.mediator.service.ActionProcessor.onMessage(ActionProcessor.java:64)+
+at oracle.tip.mediator.dispatch.MessageDispatcher.executeCase(MessageDispatcher.java:121)+
+at oracle.tip.mediator.dispatch.InitialMessageDispatcher.processCase(InitialMessageDispatcher.java:467)+
+at oracle.tip.mediator.dispatch.InitialMessageDispatcher.processCases(InitialMessageDispatcher.java:366)+
+at oracle.tip.mediator.dispatch.InitialMessageDispatcher.processCases(InitialMessageDispatcher.java:272)+
+at oracle.tip.mediator.dispatch.InitialMessageDispatcher.dispatch(InitialMessageDispatcher.java:138)+
+at oracle.tip.mediator.serviceEngine.MediatorServiceEngine.process(MediatorServiceEngine.java:655)+
+at oracle.tip.mediator.serviceEngine.MediatorServiceEngine.post(MediatorServiceEngine.java:481)+
+at oracle.integration.platform.blocks.mesh.AsynchronousMessageHandler.doPost(AsynchronousMessageHandler.java:142)+
+at oracle.integration.platform.blocks.mesh.MessageRouter.post(MessageRouter.java:194)+
+at oracle.integration.platform.blocks.mesh.MeshImpl.post(MeshImpl.java:204)+
+at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)+
+at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)+
+at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)+
+at java.lang.reflect.Method.invoke(Method.java:597)+
+at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:296)+
+at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:177)+
+at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)+
+at oracle.integration.platform.metrics.PhaseEventAspect.invoke(PhaseEventAspect.java:59)+
+at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:166)+
+at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)+
+at $Proxy195.post(Unknown Source)+
+at oracle.integration.platform.blocks.adapter.fw.jca.mdb.AdapterServiceMDB.onMessage(AdapterServiceMDB.java:509)+
+... 10 more+
+Caused by: BINDING.JCA-12563+
+Exception occured when binding was invoked.+
+Exception occured during invocation of JCA binding: "JCA Binding execute of Reference operation 'Put' failed due to: Error in logging in.+
Error in logging in.
Unable to log in to the server.
+".+
+The invoked JCA adapter raised a resource exception.+
+Please examine the above error message carefully to determine a resolution.+
+at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.executeJcaInteraction(JCAInteractionInvoker.java:427)+
+at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.invokeJcaReference(JCAInteractionInvoker.java:530)+
+at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.invokeAsyncJcaReference(JCAInteractionInvoker.java:49+
+4)+
+at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAEndpointInteraction.performAsynchronousInteraction(JCAEndpointInteractio+
+n.java:463)+
+at oracle.integration.platform.blocks.adapter.AdapterReference.post(AdapterReference.java:244)+
+... 52 more+
+Caused by: BINDING.JCA-11439+
+Error in logging in.+
+Error in logging in.+
+Unable to log in to the server.+
+Please ensure userid and password specified to login to the server is correct.+
+at oracle.tip.adapter.ftp.FTPClient.regularLogin(FTPClient.java:1614)+
+at oracle.tip.adapter.ftp.FTPClient.login(FTPClient.java:1561)+
+at oracle.tip.adapter.ftp.FTPAgent.login(FTPAgent.java:1094)+
+at oracle.tip.adapter.ftp.FTPAgent.preCall(FTPAgent.java:1515)+
+at oracle.tip.adapter.ftp.FTPAgent.validateOutputDir(FTPAgent.java:1154)+
+at oracle.tip.adapter.file.outbound.FileInteraction.validateDirectory(FileInteraction.java:2726)+
+at oracle.tip.adapter.file.outbound.FileInteraction.executeFileWrite(FileInteraction.java:548)+
+at oracle.tip.adapter.ftp.outbound.FTPInteraction.execute(FTPInteraction.java:238)+
+at oracle.integration.platform.blocks.adapter.fw.jca.cci.JCAInteractionInvoker.executeJcaInteraction(JCAInteractionInvoker.java:297)+
+... 56 more+I've an ftp adapter configured to read from windows server(SOA server running on IBM AIX, filezila on Windows server). I've provided the hostname,username,password, accountname,ftpAbsolutePathBegin as /, port as 21.
I've set listParserKey to WIN.
Still FTPAdapter is unable to read from Windows server.
I'm able to get, delete etc from ftp commands through putty.Port 21 is open.
Any clue? -
How to fetch and save file in common server using FTP in SAP
Dear All,
My requirement is to fetch a image and save an image in a common server through SAP .
I think there is some concept of doing the same using FTP.
Please put some light on this issue.
REgards,
AmrutaHi,
Below are the FM's use to FTP.
FTP_CONNECT Connect to FTP server
FTP_COMMAND Execute FTP Command
FTP_DISCONNECT Disconnect from FTP server
You can search SDN for more details on each of the FM's.
Hope this helps
Regards
Shiva -
How to connect connect server through FTP?
hi all,
i am new to FTP protocol. i want to develop a program using FTP. can any one give me a correct suggestion or give me correct link for my reference or if u have any code then pls give me that code.i want to connect with intranet server.i had tried many ways but i cant connect to the server. pls help me.........randy_ortan wrote:
i want to develop a program using FTP.Sorry, does this mean "I want to use FTP to develop a program" or does it mean "I want to develop a program that uses FTP"?
Assuming the latter, I agree with Chester, just download Apache Commons Net and use that for your FTP client. -
Transfer a xml file from application server to another server using FTP
Hi experts,
I am stuck in this situtaion.
My interface generates a xml file on an application server.
Now i need to read the xml file generated and transfer it to another system using FTP.
I can use READ DATASET to read the file from the application server.
And use the below function modules to transfer it to another system
HTTP_SCRAMBLE.
FTP_CONNECT
CONCATENATE 'put' src_file_dest into variable.
FTP_COMMAND with command = variable.
FTP_DISCONNECT.
Now my question is:
- Is it correct????
- I am getting an cerror = 3 while using FTP_CONNECT. is it an authorization issue???
if yes, what is the issue???
- How to connect the file read from READ DATASET to the FTP Function Modules ????
Thanks and Regards
Gaurav RaghavTry the following set of FTP commands..
This code gets the file (NOT the content) from the server and sends it to the FTP.
*********start send file to FTP********************
* FTP commands : 1. ascii
* 2. cd
* 3. lcd
* 4. put
call function 'HTTP_SCRAMBLE'
exporting
source = x_pwd
sourcelen = dstlen
key = key
importing
destination = destin.
clear pass.
pass = destin.
call function 'FTP_CONNECT'
exporting
user = x_user
* PASSWORD = X_PWD
password = pass
host = x_host
rfc_destination = x_dest
importing
handle = hdl.
* COMMAND ascii -->
refresh : x_result.
call function 'FTP_COMMAND'
exporting
handle = hdl
command = cmd_ascii
compress = compress
tables
data = x_result
exceptions
command_error = 1
tcpip_error = 2.
*command cd SAP\ -->
split x_file at '\' into dummy ftp_file.
concatenate x_cmd1 dummy into dummy2 separated by space.
concatenate dummy2 '\' into cmd_cd.
refresh : x_result.
call function 'FTP_COMMAND'
exporting
handle = hdl
command = cmd_cd
compress = compress
tables
data = x_result
exceptions
command_error = 1
tcpip_error = 2.
constants: winslash(1) value '\',
unixslash(1) value '/'.
call 'C_SAPGPARAM' id 'NAME' field 'DIR_HOME'
id 'VALUE' field tempdir.
* command lcd SERVER\usr\....\DIR_HOME --?
concatenate 'lcd' tempdir into cmd_lcd separated by space.
refresh : x_result.
call function 'FTP_COMMAND'
exporting
handle = hdl
command = cmd_lcd
compress = compress
tables
data = x_result
exceptions
command_error = 1
tcpip_error = 2.
* COMMAND put file -->
concatenate 'put' ftp_file into cmd_put separated by space.
refresh : x_result.
call function 'FTP_COMMAND'
exporting
handle = hdl
command = cmd_put
compress = compress
tables
data = x_result
exceptions
command_error = 1
tcpip_error = 2.
* command ls -->
refresh : x_result.
call function 'FTP_COMMAND'
exporting
handle = hdl
command = cmd2
compress = compress
tables
data = x_result
exceptions
command_error = 1
tcpip_error = 2.
call function 'FTP_DISCONNECT'
exporting
handle = hdl.
******* end send file to FTP*****
Edited by: Iria Koutsogianni on Jan 19, 2009 11:50 AM -
Urzent: Delete files in FTP server using FTP receiver adapter
Hi Experts,
We are doing 2 asyncronous scenarios. frst scenario should delete existing file and place the request file. Second scenario should pick(delete) response file and delete request file it placed also.
Scenario 1 : File(NFS) to FTP (Asynchronous)
Scenario 2: FTP to NFS (Asynchronous)
Scenario 1: (Receiver FTP Adapter )
step-1: PI has to delete all existing files in FTP server
step-2: PI has to place Request file in FTP
Scenario-2: ( Sender FTP Adapter)
step-1: PI has to Delete request file i FTP server
Step-2: PI has to pick and delete response file in FTP server
Doubts:
How can we do above steps in PI
Thanks,
MuraliHi Krish - For scenario -1 You have to make use of the OS commands to delete the files on FTP server before placing the request file.
-> write some script which wil connect to the FTP server and delete the files.
-> call that script from the file adapter "using execute OS commands" option
For scenario -2 :
pick both the files(request and response) and set the processing mode to delete..
during the receiver determination, process only request files(based on filename/content) -
HOW to read file using ftp???
Hi to all,
I have problem with reading file using ftp connection, i want to read only 1024 bytes for one time, and i have
next code wich read this:
byte buffer[] = new byte[1024];
while( (readCount = input.read(buffer)) > 0) {
bos.write(buffer, 0, readCount);
but I dont know how to put all read data in one byte[] if i dont know length of file.
I can't do some like: byte file[] = new file[1000000];
Thanks for all sugestions!* Download a file from a FTP server. A FTP URL is generated with the following syntax:
* <code>ftp://user:password@host:port/filePath;type=i</code>.
* @param ftpServer FTP server address (incl. optional port ':portNumber').
* @param user Optional user name to login.
* @param pwd Optional password for <i>user</i>.
* @param fileName Name of file to download (with optional preceeding relative path, e.g. one/two/three.txt).
* @param destination Destination file to save.
* @throws MalformedURLException, IOException on error.
public void download(String ftpServer, String user, String pwd, String fileName, File destination) throws MalformedURLException, IOException {
if (ftpServer != null && fileName != null && destination != null) {
StringBuffer sb = new StringBuffer("ftp://");
if (user != null && pwd != null) { //need authentication?
sb.append(user);
sb.append(':');
sb.append(pwd);
sb.append('@');
}//else: anonymous access
sb.append(ftpServer);
sb.append('/');
sb.append(fileName);
sb.append(";type=i"); //a=ASCII mode, i=image (binary) mode, d= file directory listing
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
URL url = new URL(sb.toString());
URLConnection urlc = url.openConnection();
bis = new BufferedInputStream(urlc.getInputStream());
bos = new BufferedOutputStream(new FileOutputStream(destination.getName()));
int i;
while ((i = bis.read()) != -1) { //read next byte until end of stream
bos.write(i);
}//next byte
} finally {
if (bis != null) try { bis.close(); } catch (IOException ioe) { /* ignore*/ }
if (bos != null) try { bos.close(); } catch (IOException ioe) { /* ignore*/ }
}//else: input unavailable
}//download()If you don't want to strore the data into a file, use ByteArrayOutputStream instead of a FileOutputStream. -
How to download file using ftp in bash script
Hi! I'm runnig a bash script in solaris i want within the script to dowload file using ftp
How can i do it?
Tanks a lothello,evgchech
please try this way:
1. In the bash script, try following command:
ftp -n < ftpcmdfile2 in the ftpcmdfile (which is a file),coding the interactive commands of FTP such as:
user anonymous [email protected]
cd /var/sun/download
bi
mget *.*
bye
try it and good luck!
Wang Yu
Developer Technical Support
Sun Microsystems
http://sun.com/developers/support
Maybe you are looking for
-
Updated to 10.5.3, now Motion crashes on launch
Worked fine under 10.5.2. Any ideas how to fix it, short of re-installing?
-
ITunes seems to be skipping/hiccuping while playing music during browisng.
Hello Everyone So for the past month or so I experience intermittent "hiccuping" while playing music through iTunes on my PC. Songs don't skip in the traditional sense of skipping from one song to the next ... instead it's more like a blurp/drag. I
-
Do not see Set-Up System Monitoring Button
Dear Friends I have configurated the Maintenance Optimizer successfully Now I want to configure the system monitoring, but i do not see the Sep-Up system monitoring button in the T-CODE solution_manager ---> Operation Setup, I only can see the : myS
-
Message "waiting for device" on my Pc
hi, I've a N73 and i'm trying to use maps , but i can't make it works on my phone. Please, someone can send me the steps to instal the program and how to make a download of Brazil's map? Thanks.
-
Can I set html input with digital
If I use html in iphone,Can I set the "input=text" only digital allowed,just like the keyboard number pad! Thanks!