Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Opening URL in instrumented browser

by Arunbear (Parson)
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(http://www.perlmonks.org/)"] +)'


Comment on Re: Opening URL in instrumented browser
Download Code
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 http://www.perlmonks.org/]); say "hello!" ' + hello!
      That only prints "hello!" once Opera exists. Non-blocking alternatives are:
      % perl -E 'system(q[opera http://www.perlmonks.org/ &]); 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054485]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2015-07-05 13:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls