in reply to Re^2: Integrating shell cmd to perl script
in thread Integrating shell cmd to perl script

Why don't you change the shell script to perform a loop and then use either system( 1, 'shellscript') or my $pid= open( my $fh, 'shellscript |' ) to launch it in the background? You can then kill the shell script when your main program exits.

Replies are listed 'Best First'.
Re^4: Integrating shell cmd to perl script
by Anonymous Monk on Mar 25, 2015 at 09:37 UTC

    Just tried this. I created a separate shell script for snmp polling and called this shell script in the actual perl script as you suggested.

    my $pid= open( my $fh, '<path>/snmp.pl |' );

    But, after executing this am not getting the control back to the perl script. Should i use "&" after snmp.pl?

      This is weird because I launch scripts that way in the background if I plan to read their output from them. Maybe you should check whether the open() call is successful or maybe you can post a short program (10 lines or so) that demonstrates the problem.

      It looks like you need something like fork, e.g.:
      my $pid = fork; if ($pid) { # do all the other tasks here system "kill $pid"; # ready to stop the polling } else { # do the polling }

      One world, one people

Re^4: Integrating shell cmd to perl script
by Anonymous Monk on Mar 25, 2015 at 09:21 UTC

    Sounds Good. Let me give a try