This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes Calling Unix script from JSP on UNIX server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Calling Unix script from JSP on UNIX server" Watch "Calling Unix script from JSP on UNIX server" New topic
Author

Calling Unix script from JSP on UNIX server

Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
I have a JSP page using which I have to call a UNIX script.
The solution i found for this is I will have my JSP deployed on a UNIX server and it will call the UNIX script from there.


Now suppose this unix script ,I only have to transfer to UNIX server before keeping it at a particular location there and calling it.


The Problem is:

I know how to make my JSP(once deployed on UNIX) call this JSP ----FINE
But how do i transfer this UNIX script to that particular UNIX server-----I NEED SOLUTION TO THIS

thanks

Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Monica. Shiralkar wrote:
But how do i transfer this UNIX script to that particular UNIX server


Are you having multiple servers?
Why not bundle that script in the WAR to put it on a particualr server or have a properties file to contain the location of the script?
I am not getting the exact problem.


SCJP, SCWCD.
|Asking Good Questions|
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
Yes we are having having multiple servers. Now I have to create war and my war will be deployed on any unix server but how to transfer a unix script to that server.


Your idea of: bundle that script in the WAR to put it on a particualr" server sounds as solution

but my doubt is.suppose i have bundled script in the war .Now when i deploy this war.I have to keep this script at a particular location on unix server.how to transfer script from war to this unix server location where it is depoloyed.

thanks.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30361
    
150

Any reason you can't just FTP it over?

Also, be careful. The UNIX script can do anything your app server cab do. Confirm that UNIX script is well secured.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
What we want to accomplish is : We want to give this WAR to our client.our client should deploy the WAR on his unix server and Run the JSP which will call the scipt(but somehow the script needs to be transfered there)..

Is it a feasible design? Please advice .
Prasad Krishnegowda
Ranch Hand

Joined: Apr 25, 2010
Posts: 513

Why can't you give your client the script file too and tell them to put it on the UNIX server (where they deploy the war file)?


Regards, Prasad
SCJP 5 (93%)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
Monica. Shiralkar wrote:We want to give this WAR to our client.our client should deploy the WAR on his unix server and Run the JSP which will call the scipt(but somehow the script needs to be transfered there).

I see several problem with this approach. Firstly, if you don't know anything about the server where the script will run, then it's unlikely that the script will work on all of them. There's a large variety of Unix/Linux distributions and versions with many differences in paths, capabilities, environment variables, directory layout etc.

Secondly, on a Unix/Linux server a web app is very unlikely to have the rights to install or run shell scripts. On such systems it's common to use different user accounts for servers, especially to limit what they can do to the rest of the system. There may also be a security manager in place that governs what web apps can do on the Java level.

What does the script do that the web app can't do in Java code? It may be cheaper to spend a developer-month on adding those capabilities to the web app than to have to deal with the installation, maintenance and support issues of having to install a shell script over the lifetime of the web app.


Ping & DNS - my free Android networking tools app
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
The unix script is supposed to create a cluster of certain number of nodes for big data. Suppose we take care of the rest is there any way that the script can be bundled in the war and it can be transferred to certain location on unix server?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
Most likely not, due to the issues I mentioned previously.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
Apart from the issues you mentioned I understand the below :

We can bundle a unix scipt inside a WAR.the deployed app can use this script.BUT there is no way this script can be AUTOMATICALLY transferred to any particular location on the server war is deployed.(Unless manually done)

please correct me if i am wrong.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
the deployed app can use this script.

Are you sure about this? The script can only run if it's installed on the target machine, and that will be difficult due to the issues I mentioned.
Monica. Shiralkar
Ranch Hand

Joined: Jul 07, 2012
Posts: 639
the unix script we have tested to run standalone.now only thing is once this war is deployed there is there a way to tansfer this war to particular location say on the unix server.?
In general for any WAR is it possible to bundle a unix script and this script will be transfered to cetain location on the unix server.?

thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41599
    
  55
Maybe. Maybe not. It depends on the issues raised in all the previous answers. Is there a way that works in general? No.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling Unix script from JSP on UNIX server