This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I want to invoke perl exe from java.It does not seem to work with Runtime.exe like the other exes.Any clue? The piece of code is Process stopRPSproc = Runtime.getRuntime().exec("perl.exe"); the call just comes out
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
First, try using the complete (absolute) path to the perl.exe file - e.g. C:\programs\perl\perl.exe or whatever. It's possible to use a relative path also, but you need to know what directory java is executing from, and where perl.exe is relative to that; if you have any problems, it's easiest to use the absolute path. If this does not work, try using the Process method getErrorStream(), read from the InputStream it gives you, and print the results to your screen or a file somewhere. Chances are good there's an error message here which will give you further clues. Good luck.
"I'm not back." - Bill Harding, Twister
shanmuga perumal
Greenhorn
Joined: Sep 14, 2003
Posts: 2
posted
0
Can I get the output from perl file, which can be invoked by .java file For Example Process p = Runtime.getRuntime().exec("perl filename.pl argument.txt")
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
1
posted
0
Look at the java.lang.Process API - in particular the getErrorStream getInputStream getOutputStream methods. These methods let you read and write the standard in, out and err streams that Perl uses If your Perl program writes output to the screen you must read it or the Perl program may hang. Separate threads for reading the out and err are a good idea. Bill
Hi Brogden, Shall I use perl language in jsp tags instead of java. Pls explain with example
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
1
posted
0
If you start Perl, it is going to expect input of a Perl program from somewhere - usually from a file - plus possibly command line parameters. The only control you would have from JSP would be in setting up the command line to Perl. Bill
raimondas zemaitis
Ranch Hand
Joined: Feb 23, 2001
Posts: 104
posted
0
On a windows 2000 you should do in the following way to invoke external process (doesn't matter perl or other, BTW, I had to invoke Perl scripts in our current script and this works great): String[] command = new String[3]; command[0] = "cmd.exe"; command[1] = "/C"; command[2] = "perl.exe"; Process proc = Runtime.getRuntime().exec(command);