• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

calling a perl script from java program

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to execute a perl script from a java program, I got some stuff on google:


It gives me the output as: Command Successful
but I need to see the output which should be: "I have a no" (which is there in basic.pl)

also I tried running another script - which should create a txt file ( that is not happening either)

any help is appreciated.
Thanks!
 
Marshal
Posts: 80267
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to "drain" both Streams associated with the Process, not only the input stream. The ProcessBuilder class makes that a little easier in Java5, but you can get all sorts of problems with Processes if you don't start a parallel thread. For details look for Michael Daconta's classic article "When Runtime.exec() won't"
 
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
When running a Process, you should provide for consuming both std out and std err streams. Your code waits for the Process to end, but does not consume the output while the process is running. This is a recipe for disaster since the process may hang trying to output to std out or std err.

Bill
 
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic