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