• 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
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

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: 22271
119
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
 
Don't mess with me you fool! I'm cooking with gas! Here, read this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic