• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet calling remote script

 
Kop Ite
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
How do I code my servlet such that it can call a script ( Korn, Perl etc) on another Unix box (e.g. dsn123) ?
I guess that i'd need to be using Runtime.getRuntime().exec ??
.... Runtime.getRuntime().exec(" ../host/home/third/script.pl")
cheers
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Won't that be a security violation?
 
Kop Ite
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to call a script on another UNIX box from the one which the Servlet is running? I thought security violations were where you're attempting to connect with another box from an applet. I am not sure whether Servlet disallows my requirement. If so that is a shame - for me - but what if the script existed on the same machine or called a script on the same machine which then pointed at another script on another machine ???
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18212
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Servlets are given a high level of trust, and I believe there are people in this forum who have successfully used the exec() function in servlets.
In order to run a script that lives on another machine, you obviously must have access to the interpreter, its runtimes, and the script, so you need an NFS connection just to be able to see the script, and a perl interpreter system needs to be available on the web host. Implicit execution of Perl isn't going to work - the "#!/usr/bin/perl" part is handled by the shell, and you're not using the shell. So you need to explicitly SAY exec("/usr/bin/perl ../host/home/third/script.pl");
Just as a general reminder - if you synchronously invoke a long-running process of any type, you may timeout on the user's browser and can have performance problems on the webserver. It's often best to make a server for the external process and play web games with it as an a synchronous service.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic