Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Opening URL in instrumented browser

by Arunbear (Prior)
on Sep 17, 2013 at 16:20 UTC ( #1054485=note: print w/replies, xml ) Need Help??

in reply to Opening URL in instrumented browser

system perhaps? e.g.
perl -e 'system(q[opera --remote "openURL("] +)'

Replies are listed 'Best First'.
Re^2: Opening URL in instrumented browser
by chris92 (Initiate) on Sep 17, 2013 at 16:51 UTC
    I need to get the control back to my perl program. I guess the above call is a blocking call??

      From the documentation on system:

      Does exactly the same thing as exec LIST , except that a fork is done first and the parent process waits for the child process to exit.

      Another alternative would be to use backticks instead of system. I personally consider this as a "quick" and "dirty" method even though I do use it a lot. There are some potential problems with using this method. Off hand I don't remember what all of the issues are, but I believe that there are better ways to launch another program and return control back to the Perl script without waiting for the launched program to return control.

      Yes, it is a blocking call:
      % perl -E 'system(q[opera]); say "hello!" ' + hello!
      That only prints "hello!" once Opera exists. Non-blocking alternatives are:
      % perl -E 'system(q[opera &]); say "hello!" +' hello!
      i.e. launching in the background, or
      % perl -E '$r = fork; if($r == 0) { exec(q[opera http://www.perlmonks. +org/]) } elsif(defined $r) { say "hello!" }' hello!
      which forks off a child process, and uses exec (so the child process doesn't hang around waiting for the browser process to end).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054485]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2018-03-24 01:16 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (297 votes). Check out past polls.