• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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: 3281
8
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: 3281
8
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: 3281
8
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.
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic