• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

perl script sending signals to java

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a perl program writing to a flat file and a java file reading from it. At some point of time the perl program should send a signal to the java program and the java on reading it should perform certain action on the flat file.

Could you please suggest how is that possible.

Mayank.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, I'm no Perl guru but can't you just get perl to execute 'java <arguments> <program>' on the 'command line'?
 
mayank gupta
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont want to execute the java program from perl. i want to send a signal from perl to an already running java app. The java app has to do some signal handling and take action according to that. Is it possible?
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, I'm not sure of the 'Perl interacting with Java' capabilities, but is there a common protocol they can talk over? e.g. RMI? Web Services? Heck even get Perl to Touch a File and the Java program has a thread which detects the file time stamp changing?
 
mayank gupta
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Touching a File option i have tried and it doesnt fir my requirements. Do you have any idea about handling signals in java?
 
mayank gupta
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please let me know something about how to handle signals in java and if perl signals can be handled as well. I tried searching but couldnt get much information. Could you please provide some pointers.
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

mayank gupta wrote:Could you please let me know something about how to handle signals in java and if perl signals can be handled as well. I tried searching but couldnt get much information. Could you please provide some pointers.



You can't handle signals in 100% Java; the standard libraries have no signal-related capabilities at all. You might be able to use native code to handle signals, especially if you write main() in C and create a JVM from your C code. Even there, though, the JVM library does some signal handling itself (mostly just crash-protection) and your added handlers may either break things or not work properly.

Instead of using signals, let the Java program create a ServerSocket to listen on a well-known port; create a Thread dedicated to listening on that socket, in a loop. Then let that thread handle a simple command language. It's a simple matter, then, for your Perl program to connect to that socket and send the desired command(s).
 
mayank gupta
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the suggestion. Is there any other way in which I can let the java program be informed when another program(perl) is renaming a file. I am not too sure about socket programming in java so it would be really nice if we could come up with something else.
 
Martijn Verburg
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you can have a thread or say a quartz driven timer to simply check the name of the file every x seconds.
 
mayank gupta
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used the non standard API for the time being (to handle the signals) rather than going through the pain of the Native code.

Thank You.
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic