SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Starting a browser from a perl program

    I suspect my problem is more with the Yahoo website or the DOS box, than with perl, but I see no forum devoted to those matters.

    Basically, I'm trying to start a yahoo web page out of a perl program, using backquotes.

    That actually works quite well, but somewhere between the Dos box and Yahoo the url gets mangled.

    Example:

    I can get the page I want by typing into a browser the url: finance.yahoo.com/q/hp?s=CNX&a=05

    I can get it also by putting it in backquotes in my perl program like so:
    $cmd = "start chrome.exe finance.yahoo.com/q/hp?s=CNX\%26a=05;
    $null = `$cmd`;

    However, somewhere along the line, the 'q/hp' gets replaced with 'lookup', and Yahoo says it can't find the page.

    However, if I leave off the argument as: $cmd = "start chrome.exe finance.yahoo.com/q/hp?s=CNX,
    the 'q/hp' is left in place, and the page comes up beautifully.

    There's nothing wrong with the arguments, since, if I manually edit the address bar to replace 'lookup' with 'q/hp', the argument is accepted and the page works fine.

    Has anyone else had experience starting a browser from the command line with a url that includes arguments?

  2. #2
    om nom nom nom Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,266
    Mentioned
    50 Post(s)
    Tagged
    2 Thread(s)
    Instead of the frightening backticks, you might want to use something like URI::Escape.

  3. #3
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could go this route:

    $cmd = 'start chrome.exe "finance.yahoo.com/q/hp?s=CNX&a=05"'; # the end of the string is a double quote followed by a single quote
    system($cmd);

    as long as nothing inside of the single quotes is meant to be evaluated (i.e. no variables allowed).


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •