logo       

Re: LWP::Simple - Terminal won't but BBEdit will.: msg#00005

Subject: Re: LWP::Simple - Terminal won't but BBEdit will.
On Jul 9, 2006, at 5:03 PM, Andrew Brosnan wrote:

Hi,

I came across something odd editing a script with BBEdit. The BBEdit #!
menu has a 'Run' command and a 'Run in Terminal' command. The script
below works fine when I use the Run command, but returns HTTP response
code 500 when I use Run in Terminal. I tried running it directly from
Terminal and I get the same result, HTTP response code 500.

I also noticed that getstore() returns 500 as a one-liner from Terminal
(but getprint() works fine). What gives?

Regards,
Andrew


    #!/usr/bin/perl

    use warnings;

    use strict;

    use LWP::Simple;

    my $url = 'http://www.google.com';

    my $file = 'Users/andrewbr/Desktop/google.html';

$file is a relative path. When you use "Run", the current directory is '/' (inherited from BBEdit), so the relative path resolves correctly to "/Users/andrewbr/Desktop/google.html". When you choose "Run in Terminal", or run it manually, the current directory is the directory the script lives in, so getstore() tries to store the returned data in "(current directory)/Users/andrewbr/Desktop/ google.html" - probably not what you had in mind.

getprint() works because it's not trying to write to a non-existent directory.

Easy fix - add a / to the beginning of $file to make it a fully- qualified path.

sherm--

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
science.linguis...    culture.sf.lite...    video.mplayer.c...    yellowdog.gener...    ietf.rfc822/199...    emacs.help/2002...    redhat.release....    kernel.speakup/...    java.openejb.de...    debian.devel.gt...    xfree86.newbie/...    bug-tracking.ma...    pam/2003-05/msg...    games.devel.ope...    user-groups.lin...    music.pancham/2...    network.mq.deve...    web.html.genera...    arklinux.bugs/2...    linux.ecasound/...    qnx.openqnx.dev...    org.user-groups...    file-systems.sf...    trustix.contrib...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe