Unix commands from JSP

Hi All,

I want to run simple UNIX commands like

1) ls-ltr |grep <file name>

2) renaming of a file (mv <old file name> <new file name>)

3) telnet to a remote server (telnet <server IP)

from a JSP. Is there any ay by which i can do this? If so can i have some some sample codes for reference related to this? Any kind of help will be greatly appriciated.

Thanks in advance.>

[440 byte] By [atanu.123a] at [2007-11-27 7:04:25]
# 1
Check this out, may be useful: http://java.sun.com/developer/technicalArticles/xml/WebAppDev/
skp71a at 2007-7-12 18:55:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

If you REALLY want to use unix commands (or other underlying operating system and lose all portability) you use Runtime.exec

A very useful article on it:

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

However everything you have mentioned is possible to do in Java using the libraries.

1) ls-ltr | grep <file name>

File dir = "[directory to search]";

File[] fileList = dir.listFiles( [use a filename filter here if you want])

2) Again in the java.io package take a look at the method: File.renameTo

3) use the java.net classes, or a library for telnet

I see no reason to use unix commands when there is a relatively straight-forward java equivalent.

evnafetsa at 2007-7-12 18:55:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...