0

Alright, I'll get into the meat of things straight away:

I want to run a perl script from a java app (via ProcessBuilder), which will then parse an html page and find out some required information. I then want to pass that information back to my java app, and display that information in a JTextArea.

My knowledge of perl is VERY limited. My original thought was to write this data to a txt file, and then read that file with my java program, which could then display it to JTextArea pretty easily. However, this seems like an ugly solution, compared to simply returning a string.

Please let me know if there is a better way to do this. perhaps a completely different method than what I'm thinking of. Thanks,

Aelfhere

Aelfhere
  • 171
  • 2
  • 12
  • 1
    would i be correct in assuming that you are unprepared for the flaming you ask for anytime you mention parsing an html page with perl (or any language, really)? just thought you might want to know. – MJB Jun 23 '11 at 16:30
  • as unprepared as it is reasonably possible to be. but it's not really what my question is about. i can use an html parser (such as html::parser) to get the required information. i just need to pass that information back to my java program. – Aelfhere Jun 23 '11 at 16:31
  • 1
    @MJB, what's wrong with parsing HTML pages with Perl? It has many parsers that would do that well. – Qtax Jun 23 '11 at 16:34

3 Answers3

1

I think you want something like this

Rocky Pulley
  • 22,531
  • 20
  • 68
  • 106
0

You can pass strings between processes only by using some type of inter-process communication: either a pipe or shared memory or using network.

Why can you not do in Java what you want to do in Perl?

Miserable Variable
  • 28,432
  • 15
  • 72
  • 133
  • i could do it in java... but the perl script has already been created. i just want to implement it, with possibly a few tweaks. – Aelfhere Jun 23 '11 at 17:12
0

when you use a ProcessBuilder you instantiate a Process Object it's java representation of a batch execution

Tipically you can hook process streaming via Java API.

Extracted from Process JAVA API:

  • abstract InputStream getErrorStream() Gets the error stream of the subprocess
  • abstract InputStream getInputStream() Gets the input stream of the subprocess
  • abstract OutputStream getOutputStream() Gets the output stream of the subprocess

If perl script write on standard output stream then you can read that output.

Generally, If process doesn't write on standard output stream then you cannot read it.

m.genova
  • 377
  • 6
  • 15