LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Getting error in ftp from windows to unix box (https://www.linuxquestions.org/questions/programming-9/getting-error-in-ftp-from-windows-to-unix-box-712569/)

sangeeta_linux 03-18-2009 02:00 PM

Getting error in ftp from windows to unix box
 
Hi,

I have a written a java code to ftp a file from the windows box to unix box. It keeps giving me the following error :
"java.io.FileNotFoundException: PORT 204,63,56,5,16,78: 550 Permission denied."

I am able to ftp manually from windows to unix.

Any pointers would be helpful. Thanks.

Regards,
Sangeeta

hedgy102 03-18-2009 02:10 PM

Hi,
Can you paste your code here? (Please include the imports)

sangeeta_linux 03-18-2009 03:19 PM

Hi, Thanks for the prompt resonse. Here is my code :

import java.io.* ;
import java.util.zip.*;
import java.net.*;
import sun.net.TelnetInputStream ;
import sun.net.TelnetOutputStream ;
import sun.net.ftp.FtpClient ;

import weblogic.utils.encoders.BASE64Decoder;
import weblogic.utils.encoders.BASE64Encoder;
import org.apache.log4j.PropertyConfigurator;

int len;
byte[] buf = new byte[1024];
BufferedReader in = null;
try
{
FtpClient ftp = null;
String host = strServerIP;//Computername or IP Address
ftp = new sun.net.ftp.FtpClient(host,21);
TelnetInputStream telnetInputStream = null;
//Computername or IP Address
String username = strFTPUname;
String password = strFTPPwd;
/* Decrypt the password */
String strPass = decrypt(password);
ftp.openServer(host,21);
ftp.login(username, strPass);
ftp.binary();
String hostPath=strLocationTO;
String sFilePutPath=hostPath+sFilename;
String Sourcepath= sFilePath+"abc.dat";
BufferedInputStream finStream = new BufferedInputStream( new FileInputStream(Sourcepath ) );
FileInputStream inputFile = new FileInputStream(Sourcepath);
TelnetOutputStream telOut = ftp.put( sFilePutPath);
int bytesAvailable = inputFile.available();
byte[] readByte = new byte[bytesAvailable];
int d = 0;
while( ( d = finStream.read( readByte, 0, bytesAvailable )) != -1)
{
telOut.write( readByte, 0, bytesAvailable );
}
finStream.close();
inputFile.close();
telOut.close();

hedgy102 03-18-2009 04:39 PM

Hi again,

It worked on my machine. My initial impression is that it might be something simple, like a missing trailing slash in the sFilePath?

However, please note that you are using forbidden packages:
Code:

import sun.net.TelnetInputStream ;
import sun.net.TelnetOutputStream ;
import sun.net.ftp.FtpClient ;

You might be better off using some other library.

I did a small search and found the following http://www.jibble.org/simpleftp/ which seems very straightforward to use.

sangeeta_linux 03-18-2009 08:05 PM

Thank you so much. I used apache package and it worked.

hedgy102 03-18-2009 08:18 PM

Glad to know you got it sorted out.

Good luck.


All times are GMT -5. The time now is 09:08 PM.