I want to send ftp or telnet commands on the Unix command box. I want to connect to say ftp enter user name and password and then run "ls" command
Here is what I have written so far, code to ftp.
But when I run the program I do not know what has happened? How can I do the next stage like enter "user name" "password" and finally run "ls" command for unix?????????
import java.lang.*;
import java.io.*;
I have done my own search on the web but I think I am not a good searcher on the search engine.
I would be greatful for any more more links on ftp or telnet java program with source code, preferably one with easy to understand code.
Thanks in advance.
09-17-2002, 02:38 PM
northfield
I want to integrate an ftp program into a program I am working on. I have scoured the net for reusebale code and come across a "t or Linlyn ftp program" which claims is easily integrateable into larger applications. The code is quite small so easy to understand.
The problem is did does not seem to work and gives me errors. I would be grateful if someone could tell me why I am getting the error, here is the error:
C:\My_DL_Dap\ftp in java>appletviewer t.java
Warning: <applet> tag requires width attribute.
java.security.AccessControlException: access denied (java.net.SocketPermission j
aguar.wmin.ac.uk resolve)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:270)
at java.security.AccessController.checkPermission(AccessController.java:
401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1042)
at java.net.InetAddress.getAllByName0(InetAddress.java:909)
at java.net.InetAddress.getAllByName0(InetAddress.java:890)
at java.net.InetAddress.getAllByName(InetAddress.java:884)
at java.net.InetAddress.getByName(InetAddress.java:814)
at java.net.InetSocketAddress.<init>(InetSocketAddress.java:109)
at java.net.Socket.<init>(Socket.java:118)
at Linlyn.ftpConnect(t.java:326)
at Linlyn.<init>(t.java:236)
at t.init(t.java:83)
at sun.applet.AppletPanel.run(AppletPanel.java:341)
at java.lang.Thread.run(Thread.java:536)
I would also be grateful if someone could try out the propgram and tell me if it works for them, then I could determine if it is because ftp clients are being blocked by my server. The ftp program is very small, here is the url:
1) compile the code
2) fill in everywhere it requests "your-server" "username" and "password"
3) to run appletviewer t.java
09-18-2002, 05:23 AM
Pankaj
Hi,
this is more of a question than solution. I have no experience on this but my doubt is based on my general knowledge of Java and networking. In your code you are calling an external program called ftp.exe and executing it. If my understanding of your requirement is correct then then why do you need this (any advantage?) i.e. call an external FTP program when you can create a socket directly to your FTP host on port 21 for FTP connection and work out suitable code to handle "username" & "password".
When you run an external program (ftp.exe) then you have to pass on arguments (FTP host address,username,password) to this program and not to the host directly because your java code is not requesting a connection to the FTP host.