• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using java to run a perl script

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm writing a java app that will allow users to run existing perl scripts, stylesheets and some other utilities all from a gui instead of a command line.

I can run the perl script no problem:


but if the script has users enter data via <STDIN>, does anyone know how to capture that info in the java app? In other words, the call for STDIN would prompt a dialog box to open in the java app, which would in turn pass it to the perl script?
thanks,
bp
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You communicate with the Process through the streams returned by getInputStream(), getErrorStream() and getOutputStream(), for regular output and error output from and input to the process respectively. To send data to the process' STDIN you must write to getOutputStream(). You can simply use JOptionPane or a custom dialog for letting the user enter the data, then write it to getOutputStream().

While you're at it, search for and read the Javaworld article "When Runtime.exec() won't".
 
Edmund Castermund
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have the streams set up like so:



I read console output like this:




but when I try to write to <STDIN> with this code:



I get a continuous JOptionPane dialog that re-opens every time I close it? How do I only write to the p.getOutputStream() when <STDIN> is called by the perl script?
Thanks!
bp
 
We're being followed by intergalactic spies! Quick! Take this tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic