Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run a Unix Application called from a Java Applet?????

Status
Not open for further replies.

dsosa38

Programmer
Jul 3, 2001
3
GT
We need to administrate a Unix application that runs in our office. This application is a software design tool. We need to know who is using it, time of usage, the name of the project that is being developed, etc.

So to achieve that we have created a html form in our intranet to be filled any time each user needs to open the application.

The form is verified by javascript. Then is processed by a typical perl html form script on the server. So the html response is sent back to the client and we think that this html can have an Applet embedded that calls to Unix and run the application in the client side.

I would like to know if it is possible to run a Unix command from Java, and in the affirmative case, which java function can call the Unix operative system and run a command to open the application .

I thank you for your help.


Dario
 
Hi Dario,

What OS are you using?

From what I know, it might be possible to do so but chances are very slim. It isn't worth the effort too to go through all the testing in order to know whether it is possible to do it. Reasons:-

1) if you are using Windows as your OS, applet can't call any Unix programs unless you create a connection and connect to your unix server. From there on, you will then run your program. (I don't know if it is possible to do so or not since I have seen from the Java(Sun) forum that people are having problems with simple Unix commands.)

2) Eventually, you will need to get your applet signed in order to access the remote pc's console. Otherwise, I don't think you are able to call your unix program.

3) It might hang your browser since control has been passed from the applet to the unix program and if you close your browser, most likely your Unix program will close too.

So due to so much questions, I guess it isn't worth while trying to figure out these and in the end to find it isn't possible to achieve what you want. Perhaps you can ask in the Java(Sun) forum too as there are more active people in that forum.

Hope this help,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Leo:
The network we are running has Solaris 2.8 Unix.

The idea is to manage de software tool.

We need to gather the information about tool usage.

This can be achieved through the Html form. It is verified by javascript and processed by a perl script in our Web server.

As a result our perl scritpts sends the Html with the applet embedded. The applet resides on the server as usual. It is loaded to the client. So this applet open a menu in the client screen to prompt a user to click a button if he/she wants to open the software design application. (it is started by the Unix command line in the client workstation, so we need to know which is the Java sintax to make the applet send a shell command to open the applicaton---which is mounted in each workstation at users login)

We dont care if the browser remains open while the Unix application is running.
Because it can be a method to figure the time in which the appliation is under usage. So when the client close the Unix application, or other applet can monitor the closing occurrence and send the date/time to an associated database to complete the usage record.

So if you know the sintax to make an applet run a unix command line, i will appreciate to indicate that.

Thank you

Dario Sosa
 
You can try this:-

Process p = Runtime.getRuntime().exec(cmd);

- where cmd is a String variable that contains the command you call to run your Unix Program

After that, you will have to set your JRE in your client pc to allow the Applet to run your command line.

c:\jdk1.3\jre\lib\security\java.policy
c:\program files\javasoft\jre\1.3\lib\security\java.policy

(This is the case for windows. I am not sure how it is like for Unix)


Open up both the files using the 'vi' command in Unix.

Paste this line into your file:

permission java.security.AllPermission;


So the end result would be something like:-

...

grant {
// Allows any thread to stop itself using the java.lang.Thread.stop()
// method that takes no argument.
// Note that this permission is granted by default only to remain
// backwards compatible.
// It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe.
// See " for more information.

permission java.security.AllPermission;

...

Regards,
Leon
(p.s. please remember to remove the line after testing) If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top