Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Runtime.exec(unix command)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i've a problem tryin to run exec on a jsp, i tryed using java files and jsp and both doesnt work. the source its!
mport java.io.*;
public class exec
{
public static void main(String[]argv)
{
try
{
Runtime rt = Runtime.getRuntime();
Process prcess = rt.exec("/bin/sh","-c","/APPS/webcust/car/docs/me/apis/charlie.sh");
}
catch (Exception e){}
}
}
any idea about whats the problem or sugestion to execute the same on a simple JSP file?
thanks
 
author & internet detective
Posts: 40523
825
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does this script do? What error are you getting?
If the script outputs anything, you need to explicitly handle the output.
 
Ernst Sternmann
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the sh file its just a test, it creates a txt file with the date, thats all, but its the first step before the real one (execute a c program, who execute various programs and updates on 4 db's, etc).
i dont recipe any error msg, just the sime HTTP 500 Internal Server Error
The page cannot be displayed
thanks
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm somewhat puzzled that the source you show is definately not a JSP - it's just a regular Java command-line class. If you are expecting a server to execute this file you are likely to be disappointed.
Do you have any other working jsp files to look at?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Thats just super - you throw away the anquished cries of the Java Runtime as it attempts to communicate with you.
 
Jeanne Boyarsky
author & internet detective
Posts: 40523
825
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ernst,
It creates a text file and puts it where?
 
Can't .... do .... plaid .... So I did this tiny ad instead:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic