Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Dynamic Runtime Call from JSP (not being dynamic)  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a JSP page, I am trying to run a shell script.

From the command line, I call the script like:
First Code Example

It processes just fine in this scenario.

Within the .jsp page, I originally tried
2nd Code Example

this scenario did not work. The variable that is argument1 does not get populated and the program that is being called by the shell script gives me Null-Value error. (this does not happen in the first coding example.

A co-worker told me this would be the solution:
3rd Code Example

However, this gives me the same results as in the 2nd code example.

Any suggestions on what I'm doing wrong here? The shell-script argument is not getting picked up by the Runtime Call, but I don't know how to make sure it does get picked up.

------------
(If relevant, I'm doing this on Solaris 10 using Tomcat).
-----------

thank you for your help and insights.
 
Chad Step
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a different sub-forum that would have been more appropriate for this question? I didn't see one that I thought was, but the question itself is not very specific to JSP other than that is the what the code is being implemented.

I just didn't see a SE General forum that I thought would be better.
thank you.
 
Sheriff
Posts: 67261
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General.

Not the type of thing you should be doing in a JSP (there shouldn't be any code in a JSP), but bear in mind that within a web app, there's no concept of a "current directory" and so you must always use full paths when referring to the file system.
 
Sheriff
Posts: 21747
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When Runtime.exec() won't. Read it, seriously.
 
Chad Step
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the responses.

I know having this portion in the JSP isn't a best practice...... I've got other excuses I won't bore you with

Thanks for the link, I learned a lot from this.

In the end, the code below (same as example 3 in original post) did work. I had to go clear the cache out of Tomcat.



Frustrating that that is what it was, but I'm stronger having read the article Rob posted above. I'll consider this frustration worth it.

thanks everyone, this issue is closed!
 
These are the worst of times and these are the best of times. And this is the best tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!