Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Calling Perl from Java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm trying to run perl script using java by :



Here is my perl script :



My problem is that, apparently the system() calls are not done.

Is it possible to call the command system through perl using java ?


Any idea why ?

thanks,

Apocys
 
Marshal
Posts: 27288
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Apparently"? You aren't sure?

The command shell neither knows nor cares that a Java program is executing it. So your question is the wrong one. I would start by making sure that you didn't make a bad assumption about the current working directory of that script; if you did, you would have looked in the wrong place for the supposed output files and wouldn't have found them.
 
Ranch Hand
Posts: 781
Netbeans IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to read the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html and implement the recommendations. You are falling for at least two of the traps.

In particular you must handle 'stderr' (your failure to do so meant you did not see the error message saying the perl script could not be found) and you must either specify the current working directory so the the perl scipt is found or you must specify the full path to the perl script.

i.e. Either


or

 
Sheriff
Posts: 22665
127
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or use a ProcessBuilder and call redirectErrorStream(true) on it. This will merge stdout and stderr, leaving only one stream to be read.
 
reply
    Bookmark Topic Watch Topic
  • New Topic