launch url

Discussion in 'Perl Misc' started by Nagaraju.Bussa@gmail.com, May 12, 2006.

  1. Guest

    Hi,
    I would like to know is it possible to launch a browser(Say IE) and
    execute one web url
    from perl or shell script.
    please post some code regarding the same.
    thanks

    I have code some thing like this..

    use strict;
    use URI::URL;
    use LWP::UserAgent;

    my $url = URI::URL->new("www.yahoo.com");

    my $req = HTTP::Request->new("GET", $url);
    my $ua = LWP::UserAgent->new();
    my $resp = $ua->request($req);

    if ($resp->is_success) {
    print $resp-> content;
    } else {
    exit 1;
    }


    When I execute this script, the response is printing on the unix
    console,I want this to open on a browser, please let me know your
    inputs.

    thanks,
     
    , May 12, 2006
    #1
    1. Advertising

  2. Matt Garrish Guest

    <> wrote in message
    news:...
    > Hi,
    > I would like to know is it possible to launch a browser(Say IE) and
    > execute one web url
    > from perl or shell script.
    > please post some code regarding the same.
    > thanks
    >
    > I have code some thing like this..
    >
    > use strict;
    > use URI::URL;
    > use LWP::UserAgent;
    >
    > my $url = URI::URL->new("www.yahoo.com");
    >
    > my $req = HTTP::Request->new("GET", $url);
    > my $ua = LWP::UserAgent->new();
    > my $resp = $ua->request($req);
    >
    > if ($resp->is_success) {
    > print $resp-> content;
    > } else {
    > exit 1;
    > }
    >
    >
    > When I execute this script, the response is printing on the unix
    > console,I want this to open on a browser, please let me know your
    > inputs.
    >


    Well, when you print to STDOUT you kind of have to expect the output in your
    console window. Why not just automate the browser and skip manually grabbing
    the page altogether?

    `iexplore www.somepage.com`;

    If that's not an option, save the page you get back to file and then open
    the file using IE:

    `iexplore somepage.htm`;

    (Assuming, of course, that the path to iexplore.exe is in your system path.)

    Matt
     
    Matt Garrish, May 12, 2006
    #2
    1. Advertising

  3. Mumia W. Guest

    wrote:
    > Hi,
    > I would like to know is it possible to launch a browser(Say IE) and
    > execute one web url
    > from perl or shell script.
    > please post some code regarding the same.
    > thanks
    >
    > I have code some thing like this..
    >
    > use strict;
    > use URI::URL;
    > use LWP::UserAgent;
    > [...]


    In perl, I start firefox like so:
    system ("firefox http://www.w3.org/");

    If you must use the Internet Exploder, it's executable's name is
    iexplore.exe
     
    Mumia W., May 12, 2006
    #3
  4. wrote:
    > Hi,
    > I would like to know is it possible to launch a browser(Say IE) and
    > execute one web url
    > from perl or shell script.
    > please post some code regarding the same.
    > thanks
    >
    > I have code some thing like this..
    >
    > use strict;
    > use URI::URL;
    > use LWP::UserAgent;
    >
    > my $url = URI::URL->new("www.yahoo.com");
    >
    > my $req = HTTP::Request->new("GET", $url);
    > my $ua = LWP::UserAgent->new();
    > my $resp = $ua->request($req);
    >
    > if ($resp->is_success) {
    > print $resp-> content;
    > } else {
    > exit 1;
    > }
    >


    You may want to look at

    Win32::Mechanize::IE

    http://search.cpan.org/~abeltje/Win32-IE-Mechanize-0.009/lib/Win32/IE/Mechanize.pm

    This should enable you to script IE.

    Mark
     
    Mark Clements, May 12, 2006
    #4
  5. wrote:
    > I would like to know is it possible to launch a browser(Say IE) and
    > execute one web url
    > from perl or shell script.
    > please post some code regarding the same.


    Sure, no problem.

    system ("explorer.exe http://cpan.org");

    works great.

    jue
     
    Jürgen Exner, May 13, 2006
    #5
  6. Dr.Ruud Guest

    Dr.Ruud, May 13, 2006
    #6
  7. Dr.Ruud Guest

    Jürgen Exner schreef:
    > :


    >> I would like to know is it possible to launch a browser(Say IE) and
    >> execute one web url
    >> from perl or shell script.
    >> please post some code regarding the same.

    >
    > Sure, no problem.
    > system ("explorer.exe http://cpan.org");
    > works great.


    Yuck, I tested

    perl -e "system q{explorer.exe http://cpan.org}"

    and it started MSIE, while the default browser on that system is Mozilla
    Firefox.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, May 13, 2006
    #7
  8. Dr.Ruud wrote:
    > Jürgen Exner schreef:
    >> :

    >
    >>> I would like to know is it possible to launch a browser(Say IE) and
    >>> execute one web url

    [...]
    > Yuck, I tested
    >
    > perl -e "system q{explorer.exe http://cpan.org}"
    >
    > and it started MSIE, while the default browser on that system is
    > Mozilla Firefox.


    Well, so? That's what the OP asked for:
    "to launch a browser(Say IE)"

    jue
     
    Jürgen Exner, May 13, 2006
    #8
  9. Dr.Ruud Guest

    Dr.Ruud schreef:
    > Matt Garrish:


    >> `iexplore www.somepage.com`;

    >
    > It is not a good practice to use the browser's executable by name.
    > Alternatives:
    > C:\> start http://www.google.com /B


    "start" behaves differently on Win-9x/ME/NT/2k/XP.
    AFAIK, it is a "builtin" on XP.


    > http://www.hcoms.co.uk/know/know_detail.php?id=371 (VB-code)
    > http://vb.mvps.org/samples/project.asp?id=hyperjmp (VB-code)
    > C:> rundll32.exe url.dll,FileProtocolHandler http://www.google.com
    > C:> rundll32.exe url.dll,FileProtocolHandler www.google.com


    I think you need rundll.exe for Win9x/ME, so an an OS-test (or a fall
    back) is needed.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, May 13, 2006
    #9
  10. Dr.Ruud Guest

    Jürgen Exner schreef:
    > Dr.Ruud:
    >> Jürgen Exner:
    >>> :


    >>>> I would like to know is it possible to launch a browser(Say IE) and
    >>>> execute one web url

    > [...]
    >> Yuck, I tested
    >>
    >> perl -e "system q{explorer.exe http://cpan.org}"
    >>
    >> and it started MSIE, while the default browser on that system is
    >> Mozilla Firefox.

    >
    > Well, so? That's what the OP asked for:
    > "to launch a browser(Say IE)"


    I read that differently, the "Say" expressed to me that the poster
    actually aimed for the default browser. But I am very biased in this
    area. One is what one reads.

    One just doesn't do that: to start the non-default browser. Unless one
    likes to be hated of course. McAfee did it for a while, maybe they still
    do. Microsoft still does it for Windows Update.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, May 13, 2006
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Buchan
    Replies:
    2
    Views:
    554
    Kevin Buchan
    Jan 22, 2004
  2. Jon paugh
    Replies:
    1
    Views:
    943
  3. Sam Iam
    Replies:
    0
    Views:
    387
    Sam Iam
    Oct 19, 2003
  4. RyGa
    Replies:
    0
    Views:
    255
  5. Just D.
    Replies:
    0
    Views:
    549
    Just D.
    Aug 11, 2004
Loading...

Share This Page