Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

win32 browser launching weirdness

by daemonchild (Acolyte)
on Jan 04, 2001 at 06:41 UTC ( [id://49680]=perlquestion: print w/replies, xml ) Need Help??

daemonchild has asked for the wisdom of the Perl Monks concerning the following question:

hello

i am having a peculiar problem, and would appreciate some help.

what i want to do is launch a browser to view a local file my script creates. i seem to be unable to do this. i have searched the archives and come across this node, which while it does offer a solution, i would prefer not to install a module on 20 different machines at work.

anybody have an idea as to why the following doesn't work?

system('c:/path/to/browser',"file://path/to/file");
doesn't work? it appears to drop the path to the browser in the address field in the browser despite any modifications i make.

much thanks, and any responses appreciated

-- steve

Replies are listed 'Best First'.
(crazyinsomniac) Re: win32 browser launching weirdness
by crazyinsomniac (Prior) on Jan 04, 2001 at 10:43 UTC
    I don't recall dos liking long names or spaces in them, so here goes, tried and true:
    my $file = 'd:/My Documents/xxxl.html'; $file = Win32::GetShortPathName("$file"); system("start $file"); # the above opens $file in the default browser or currently open brows +er # the below opens $file in a new copy of iexplore my $file = 'd:/My Documents/xxxl.html'; my $browser = 'c:/Program Files/Internet Explorer/iexplore.exe'; $browser = Win32::GetShortPathName("$browser"); system("$browser $file"); # or system("start $browser $file");
    UPDATE:
    i also tried lolindraths method, and it'll work assuming you have a short pathname(8.3 format or something). Start works equally as well:) my $Result = `start d:\\MyDocu~1\\xxxl.html`;

    "cRaZy is co01, but sometimes cRaZy is cRaZy".
                                                          - crazyinsomniac

Re: win32 browser launching weirdness
by $code or die (Deacon) on Jan 04, 2001 at 17:14 UTC
    This code is Adapted (only very slightly) from Chapter 19 of Learning Perl on Win32 Systems by O'Reilly
    use Win32::OLE; Win32::OLE::CreateObject("InternetExplorer.Application.1", $ie) || die + "CreateObject: $!"; $ie->{Visible} = 1; $ie->Navigate("file://c|/websites/site1/page.htm");
    This will open Internet Explorer using OLE and open the file "c:\websites\site1\page.htm"

    I love the Perl CD BookShelf! It has this book and other O'Reilly greats.
Re: win32 browser launching weirdness
by lolindrath (Scribe) on Jan 04, 2001 at 07:17 UTC
    This worked on my machine, might want to try it on a few of yours before you go with it.
    my $Result = `explorer c:/path/to/file.html`;


    --=Lolindrath=--
Re: win32 browser launching weirdness
by Anonymous Monk on Jan 05, 2001 at 06:17 UTC
    hey, thanks everyone for yr help

    everything's working fine now ...

    and i'll have to check out the perl cd bookshelf ... one of those things i've been meaning to pick up.

    cheers,

    -- steve

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://49680]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-18 11:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found