LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2009, 03:00 PM   #1
sangeeta_linux
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Rep: Reputation: 0
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
 
Old 03-18-2009, 03:10 PM   #2
hedgy102
Member
 
Registered: Mar 2009
Distribution: Debian,Centos
Posts: 30

Rep: Reputation: 16
Hi,
Can you paste your code here? (Please include the imports)
 
Old 03-18-2009, 04:19 PM   #3
sangeeta_linux
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Post

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();
 
Old 03-18-2009, 05:39 PM   #4
hedgy102
Member
 
Registered: Mar 2009
Distribution: Debian,Centos
Posts: 30

Rep: Reputation: 16
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.
 
Old 03-18-2009, 09:05 PM   #5
sangeeta_linux
LQ Newbie
 
Registered: Mar 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you so much. I used apache package and it worked.
 
Old 03-18-2009, 09:18 PM   #6
hedgy102
Member
 
Registered: Mar 2009
Distribution: Debian,Centos
Posts: 30

Rep: Reputation: 16
Glad to know you got it sorted out.

Good luck.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble transferring files from a Windows box to a UNIX box. BreakTheWindows2008 Linux - Software 4 08-15-2008 10:10 PM
FTP files from DOS box to LINUX box lobo1 Linux - Software 4 06-02-2005 11:57 AM
FTP from Wintel box to AIX box DriveMeCrazy AIX 6 03-19-2005 07:31 AM
autmatic ftp: from unix to windows spyghost Programming 11 08-27-2003 12:57 AM
autmatic ftp: from unix to windows spyghost Solaris / OpenSolaris 3 08-25-2003 07:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration