Invoke perl Script from JAVA in UNIX

Joined
Dec 17, 2007
Messages
1
Reaction score
0
Hello All,
I have some issue in passing parameters to perl script as command-line argument in UNIX. I have a java code which will invoking a perl script
For example:

If i invoke a perl scripts from JAVA runtime with following arguments like

perl test.pl "Testing for perl innvocation" "sample" "test.cfg"

Perl interprets as 6 argument but in reality it is 3 arguments. Even space is interpreted as an argument. Same command if i invoke from shell script it works fine but when i invoke this from JAVA in UNIX environment it fails.

Below is the source code:

Here perlInput is
perl test.pl "Testing for perl innvocation" "sample" "test.cfg"

// Execute perl script.
Process prcess = Runtime.getRuntime().exec( perlInput.toString() );
input = new BufferedReader( new InputStreamReader( prcess.getInputStream() ) );
perlResult = new StringBuffer();
// Check if executing perl script returned result or error
if( input == null )
{
error = new BufferedReader( new InputStreamReader( prcess.getErrorStream() ) );
}

while ( ( line = input.readLine() ) != null )
{
perlResult.append( line );
}
}


Any help on this is appreciated. Same code work in windows environment.

Thanks in Advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top