Is it Possible to Run Shell Script in Browser - java

Sorry if you are thinking this as Basic question. I am Having shell scripts which accepts Some parameters as Inputs to Run the Script.
Is it Possible to Pass these Parameters through Web form and Run the Shell script through Browser.
How to implement this using java if Possible. or any other technology is Best.
Thanks in Advance. Looking forward for your valuable Advice's.
Edit:-
Hi All,
Currently I am having an GUI which runs Scripts on Client Computer by accepting Some parameters. I want to keep those Shell Scripts on Server and Run by passing parameters using Web form. Sorry if my language is difficult to understand.

You would need to use a Java Applet with heightened security privileges and a JavaScript API so that JavaScript in the page could read the form data and pass it to the applet. The client computer would need to have the Java plugin and whatever shell you were using installed, and the user would have to accept the above-normal-security-level access rights the applet asked for.
This isn't in the least bit practical for the WWW and is rather a stretch for a controlled network.

You can run a script using a signed applet.

Related

How to call a shell script from UI with out App server and web server?

I have a shell script and argument as a date. I'm looking for some help in design, where I will have to create a UI and pass the date, so that it will call the shell script with an argument (it should open unix terminal and call the shell script with username and password). The whole shell script runs on LINUX server. I would preferably be on MarkLogic/Java/Unix and Scala. I should not use web server in my application.
Can someone please suggest how to call the shell script from Java application with out using an Appserver/Webserver.
I find your actual question quite confusing and even more so after your clarification to nhouser9.
What I interpret is :
1) You need a user interface (but not a terminal?)
- Your simple need may be addressed with the tried and true old timer Java Abstract Windows Toolkit (AWT). Have a look at the wikipedia page: https://en.wikipedia.org/wiki/Abstract_Window_Toolkit
The sample code there compiles into a very simple Hello World GUI. (Java package info here: https://docs.oracle.com/javase/8/docs/api/java/awt/package-summary.html)
2) You need to call a shell script from Java:
Then for this part of the question, have a look at nhouser9's original comment. That answer can be found here: calling-shell-script-from-java The heart of this is ProcessBuilder
Add 1 and 2 together and you can create a GUI to take a parameter and then execute a shell script.

How PHP script can be called using Java Applet

I want to access user's scanner using PHP script. I know this can be done by using PHP script on Linux based machine.
I want to put this script on the server and wanted to run it via Java Applet I don't know Java much also I am not sure if this task can be done by this way.
Please suggest if this is correct way and How to proceed on it.
Thanks for your time!
Can the scanner PHP code be operated purely via parameters in the URL? If so, then a Java applet could connect to those URLs passing parameters as necessary, and if the PHP script returns information in the HTML output stream (as if it were returning a web page), then the applet can parse the page it 'downloads' from that URL to get the information out. Not elegant, but do-able.

Retrieve a list of browsers/agents installed in client system

I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it.
Is this possible without asking the user to download any scritps/exe's?
If so, is it possible via java script?
I am planning to use python/django to write the entire app. Any input would be much appreciated.
EDIT : Comments on feasibility in java also much appreciated
Short answer: No, it is not possible
Long answer: This is something that any sane (operating) system designer / administrator would try to prevent - scanning of local system by a web page. However, you could use a plug-in component, such as a java applet, to do so - but in practice you probably would need to handle each client platform (OS) separately, since each of them has a different way of storing the information of installed software
You want to access the data from the client side so from the conceptual/logically its not good to access the client system. You have to use some medium which run on client side on behalf of server.
JavaScript and JavaApplet is good in this. You can get the data by JavaScript or Applet and in backend you can send data to the server.
You cannot do this unless you have some signed control installed on the client computer; or have them download a program which runs (separate from a browser) and sends the information to your server, where your django app can access it.
This is not possible using javascript (as it runs in a sandbox).
"Scanning" a client from a server may be possible if you break their security or get them to break it for you through some extension (see windows udate, for example). Either way, it's evil.

Is it possible to get a list of running processes using an applet?

I'd like to get the list of running processes using a java applet running in a browser. My understanding is that, as long as the applet is signed, it will be able to get this information. Is this accurate? Is this possible with an unsigned applet? Finally, are there any FOS applets available that I could take a look at?
Thanks.
An applet needs to be signed whenever it want to access/execute local system resources. This includes executing Runtime#exec() or ProcessBuilder which is required to be able to get a list of running processes.
You can find here a basic example how to get that list in Windows. I'd suggest to check if (System.getProperty("os.name").startsWith("win")) before continuing with that.
Porting the given example into an applet isn't that hard, just let the class extend JApplet and execute the whole code from inside AccessController#doPrivileged().
As to signing the applet, you can either sign it manually, the enduser would only face a security warning with a confirmation whether to execute it or not, or you can let it sign by a 3rd party company for some $$$, e.g. VeriSign, this way the enduser won't face the security warning. Not signing it will cause the applet not be able to run at all.
You'll have to execute OS-specific commands (through Runtime.getRuntime().exec), like tasklist.exe for windows and ps for unix-like systems.
As for security measures, I'm pretty sure it's impossible in standard 'sandbox', but 'privileged' applet can do it.

Sending HTML Form Data to Java

I have a Java program that I'm trying to interact with over the web.
I need to gather form data from the user on a Drupal site that I don't have any control over, send it to the Java program, and send the output back to the user. The Java program needs to load a lot of libraries every time it's run, so it needs to be up waiting for data from the user.
It'd be best for me to just have an HTML form for the input. What's the simplest way to deal with HTML form data using Java?
Also, I'm trying to call the Java program from a shell script. I want the program running in the background though so the libraries are loaded in advance. So ideally, I could use the server I set up for both applications.
Thanks for any help.
It sounds like you really just want to write a servlet (or use a higher level web framework, but a servlet would work fine). That makes it very easy to get web form data - you just ask for values by name, basically.
You could then "script" the application using curl, wget or something similar to make requests to the servlet.
Apologies if this doesn't answer your question - I'm finding it slightly tricky to understand exactly what you're trying to do, particularly as there are multiple layers of web UI involved, as far as I can see.
The easiest way to make POST requests with java is to use the Apache HttpClient or the more recent HttpComponents libraries.

Categories

Resources