The Artima Developer Community
Sponsored Link

Java Answers Forum
FTP login works in Windows but not in UNIX

1 reply on 1 page. Most recent reply: Jun 6, 2002 5:16 AM by Prasanna

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Van

Posts: 1
Nickname: van
Registered: Apr, 2002

FTP login works in Windows but not in UNIX Posted: Apr 15, 2002 11:44 AM
Reply to this message Reply
Advertisement
I am new to java program and debugging an existing code. This code is to FTP a file to the mainframe system. This code works perfectly if the running environment is windows but it fails in Unix (It is prompting for the password).
I am here by pasting a part of the code. If anyone has input please help me.

This is the serious action taking place in the windows platform


Inside DoCommand user m10035
Inside getreply 220-TCPFTP1 IBM FTP CS V1R2 at MVSAA00, 11:10:07 on 2002-04-14.
Inside getreply 220 Connection will close if idle for more than 5 minutes.
Inside DoCommand pass er2$dr01
Inside getreply 331 Send password please.
Inside DoCommand site blocksize=9320 lrecl=932 recfm=vb


This is the serious action taking place in the unix platform. I am getting a null value instead of (331 Send password Please).

Inside DoCommand user m10035
Inside getreply 220-TCPFTP1 IBM FTP CS V1R2 at MVSAA00, 11:22:25 on 2002-04-14.
Inside getreply 220 Connection will close if idle for more than 5 minutes.
Inside DoCommand pass er2$dr01
Inside getreply null
4/14/2002 11:28:59 AM- FtpPut.java :: LoginToRemoteServer() : java.lang.NullPointerException
rc2 false







public static int getreply(DataInputStream is) throws Exception
{
String sockoutput;

// get reply (intro)
do {
sockoutput = is.readLine();
System.out.println("Inside getreply " + sockoutput);
// log(" sockoutput " + sockoutput );
}
while (!(Character.isDigit(sockoutput.charAt(0))
&& Character.isDigit(sockoutput.charAt(1))
&& Character.isDigit(sockoutput.charAt(2))
&& sockoutput.charAt(3) == ' '));

return (Integer.parseInt(sockoutput.substring(0, 1)));

} // end getreply



public static boolean LoginToRemoteServer(
String FTP_SITE,
String FTP_USER,
String FTP_PWD)
{
try
{
int i = Ftp.ConnectTo(FTP_SITE, "21");
i = Ftp.DoCommand("user " + FTP_USER, "");
i = Ftp.DoCommand("pass " + FTP_PWD, "");
return true;
}
catch (Exception e)
{
log(
Utilities.getFormattedCurrentTime()
+ "- FtpPut.java :: LoginToRemoteServer() : "
+ e.toString());
return false;
}

}



public static int ConnectTo(String IPAddress, String PortAddress) throws Exception
{
PortAddr = Integer.parseInt(PortAddress);
IPAddr = IPAddress;
if (IPAddress == "")
{
log("Usage: java Ftp host");
System.exit(1);
}

echoSocket = new Socket( IPAddress, PortAddr);
os = new PrintStream(echoSocket.getOutputStream());
is = new DataInputStream(echoSocket.getInputStream());
return 1;
}


public static int DoCommand(String userInput, String ldir) throws Exception
{
System.out.println("Inside DoCommand " + userInput + " " + ldir);
if (echoSocket != null && os != null && is != null)
{
if (userInput.startsWith("list") || userInput.startsWith("nlst"))
{
getreply(is);
doDataPort(userInput, false, is, os);
}
else if (userInput.startsWith("retr") || userInput.startsWith("get"))
{
getreply(is);
doDataPort(userInput, true, is, os);
}
else if (userInput.startsWith("rest"))
rest(userInput, is, os);
else if (userInput.startsWith("stor"))
{
pause(2000);
if (!upload(userInput, ldir, is, os))
{
return 0;
}
}
else
{
os.println(userInput);
int temp1 = getreply(is);
return temp1;
} // end else
} // if echosocket
return 1;
}


Prasanna

Posts: 11
Nickname: pras
Registered: May, 2002

Re: FTP login works in Windows but not in UNIX Posted: Jun 6, 2002 5:16 AM
Reply to this message Reply
Dear van,
I am currently doing a project in which I have to transfer files from one computer to another using FTP/Secure FTP.Both the systems run Win2k/nT.
I have absolutely no idea how to do this from a Java application.Can you help me out,if possible?
Thanx ,
Pras.

Flat View: This topic has 1 reply on 1 page
Topic: Quicksort vs Collections.sort() Previous Topic   Next Topic Topic: class not found

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use