LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   filename truncation Perl (https://www.linuxquestions.org/questions/programming-9/filename-truncation-perl-316514/)

belmer2 04-23-2005 06:57 PM

filename truncation Perl
 
Hi All,

I seem to have an environment issue. The code below works fine on FreeBSD 4.9, however when on my Fedora box, $fname gets the first 4 characters cut off when I do the ImageMagick read request. The temp file gets generated with full file name. Error below.

I am fairly new at this, so I'm not sure if it could be an IM, or Perl problem as well. IM 6.2.1 with JPEG and 8bit color depth. Perl 5.8.6

-Chris


$fname_temp = 1;
$fname = `mktemp $temppath/colors.XXXXXXXXXXX`;
chomp $fname;

$ua = LWP::UserAgent->new;
#~File gets written here fine.
$resp = $ua->request(
HTTP::Request->new(GET => $ARGV[0]),
$fname
);
if ( ! $resp->is_success() ) {
unlink($fname);
print 'ccol.pl: Request error: ' . $resp->status_line . "\n";
exit 1;
}
}
else {
$fname = $ARGV[0];
}

##################################### Read image #####################################
$image = Image::Magick->new;
#~IM can't find it because of the 1st 4 characters being truncated here.
$str = $image->Read($fname);
$str && die $str;

ERROR
<h1>Software error:</h1>
<pre>Exception 430: unable to open file `ors.AudRlow3205': No such file or directory at code.pl line 100.</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.

puffinman 04-24-2005 01:31 PM

Looks like you've got an extra bracket after the if clause, and could you maybe throw some code tags around the code? Variable width font makes it difficult to read code, at least for me. :study:

So it looks like right before you're loading it with IM you're assigning $fname from the @ARGV array (in the else). Did you check what was in @ARGV? What is the calling syntax? :scratch:

Sorry about the smilies, I'm feeling giddy right now for some reason. :D


All times are GMT -5. The time now is 10:48 PM.