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

3
  • 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. Commented Jun 23, 2011 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. Commented Jun 23, 2011 at 16:31
  • 1
    @MJB, what's wrong with parsing HTML pages with Perl? It has many parsers that would do that well. Commented Jun 23, 2011 at 16:34

3 Answers 3

1

I think you want something like this

Sign up to request clarification or add additional context in comments.

Comments

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?

1 Comment

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.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.