Hallo,
ich brauch für mein Projekt eine Lösung, um im Programm angefertigte log.txt Dateien zu einem externen Server automatisch hochzuladen. Ich hab's lange probiert aber nie hinbekommen. Der häufigste Fehler war:
org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
Server Reply: SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u4
[...]
at Main$2.actionPerformed(Main.java:115)
Mit diesem Code:
Kennt einer von euch vielleicht mein Problem und weiß, wie damit umzugehen ist?
lg
PS: Gibts ne Code formatierung? Ansonsten https://hastebin.com/ugizosuhet.cs
ich brauch für mein Projekt eine Lösung, um im Programm angefertigte log.txt Dateien zu einem externen Server automatisch hochzuladen. Ich hab's lange probiert aber nie hinbekommen. Der häufigste Fehler war:
org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
Server Reply: SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u4
[...]
at Main$2.actionPerformed(Main.java:115)
Mit diesem Code:
Java:
public FileTransfer() {
// get an ftpClient object
FTPClient ftpClient = new FTPClient();
FileInputStream inputStream = null;
try {
// pass directory path on server to connect
ftpClient.connect(server, port);
// pass username and password, returned true if authentication is
// successful
boolean login = ftpClient.login(user, pass);
if (login) {
System.out.println("Connection established...");
inputStream = new FileInputStream("secret.txt");
boolean uploaded = ftpClient.storeFile("secret.txt",
inputStream);
if (uploaded) {
System.out.println("File uploaded successfully !");
} else {
System.out.println("Error in uploading file !");
}
// logout the user, returned true if logout successfully
boolean logout = ftpClient.logout();
if (logout) {
System.out.println("Connection close...");
}
} else {
System.out.println("Connection fail...");
}
} catch (SocketException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
ftpClient.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Kennt einer von euch vielleicht mein Problem und weiß, wie damit umzugehen ist?
lg
PS: Gibts ne Code formatierung? Ansonsten https://hastebin.com/ugizosuhet.cs
Zuletzt bearbeitet von einem Moderator: