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