Click to See Complete Forum and Search --> : newbie "Hello World" HELP


emin3m
11-08-2005, 02:00 PM
i am using vDeck hosting panel

my server is
perl version
perl, v5.8.3

path to sendmail
/usr/sbin/sendmail

path to perl
/usr/bin/perl

perl module paths
/usr/local/lib/perl5/5.8.3/i386-freebsd
/usr/local/lib/perl5/5.8.3
/usr/local/lib/perl5/site_perl/5.8.3/i386-freebsd
/usr/local/lib/perl5/site_perl/5.8.3
/usr/local/lib/perl5/site_perl


#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";

this gives me "Premature end of script headers" error
iev tried #!/usr/bin/perl -w but still no use CHMOD from 755 to 777 both ends up with same error
i finally need to do this

#!/usr/bin/perl
use Image::Magick;
$image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->Write(filename=>'shared/image.png', compression=>'None');

can any one help

Ultimater
11-08-2005, 03:02 PM
Weird, give this a try:

#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

print header();
print "Hello, World.";

emin3m
11-08-2005, 03:33 PM
OMG 1337 yupiee!!!!
thanx a lot

emin3m
11-08-2005, 03:35 PM
lolx
this is also working now
with CHMOD 755
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print "Hello, World.";

emin3m
11-08-2005, 03:37 PM
so what should i add before this to make this code work
what is Image Magick module path
and how we define module path
use Image::Magick;
$image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->Write(filename=>'shared/image.png', compression=>'None');

Ultimater
11-08-2005, 04:31 PM
Good to hear you got the hello world example to work.
As far as using the Image::Magick (http://search.cpan.org/~jcristy/PerlMagick-6.24/Magick.pm) module, I've never used it and wouldn't know.
Best wait for Jeff Mott, Nedels, or fireartist to help you.

emin3m
11-08-2005, 04:38 PM
when i use this code
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

print header();
print "Hello, World.";
use Image::Magick;
$image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->Write(filename=>'shared/image.png', compression=>'None');
it gives this error
Can't locate Image/Magick.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.3/i386-freebsd /usr/local/lib/perl5/5.8.3 /usr/local/lib/perl5/site_perl/5.8.3/i386-freebsd /usr/local/lib/perl5/site_perl/5.8.3 /usr/local/lib/perl5/site_perl .) at m33.cgi line 8.
BEGIN failed--compilation aborted at m33.cgi line 8
and this seems like IMAGE MAGICK is not installed !??????
but server information shows that they have installed image Magick :/
is any thing worng here
BTW thanx again ultimater

Ultimater
11-08-2005, 04:47 PM
First off, if you are gonna use the "strict" module, you need to predefine you variables with "my".

#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

print header();
print "Hello, World.";
use Image::Magick;
my $image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->Write(filename=>'shared/image.png', compression=>'None');

Or you can omit the strict module or comment-out the strict module and not have to include the mys:

#!/usr/bin/perl -w
#use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

print header();
print "Hello, World.";
use Image::Magick;
$image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->Write(filename=>'shared/image.png', compression=>'None');


As far as installing the module, you can get the source for the module here:
source of "Image/Magick.pm" (http://search.cpan.org/src/JCRISTY/PerlMagick-6.24/Magick.pm)

I hope you know how to install modules on your server however I doubt you do so in the mean time, just make a sub-directory in the directory of your PL file called "Image" and put the "Magick.pm" file in there for now. This isn't called installing the module because installed modules are accessible the same way from directory to directory (otherwise you'd need to do something like:

my $myCgiBin="$ENV{'DOCUMENT_ROOT'}/cgi-bin/";
require "$myCgiBin/Image/Magic.pm";

).

emin3m
11-08-2005, 04:56 PM
yea i got it about strict!
but both ways it still gives the same error

error seems to be on line
use Image::Magick;
as it mentions that it cant find the magick.pm module file in all module library folders
:(
i have asked my hosting providers to, they will reply in a day :(

Ultimater
11-08-2005, 05:12 PM
The module is non-standard and it isn't expected to already be installed on your server.
You got the source
http://search.cpan.org/src/JCRISTY/PerlMagick-6.24/Magick.pm
You got the tar.gz file
http://search.cpan.org/CPAN/authors/id/J/JC/JCRISTY/PerlMagick-6.24.tar.gz
You know where to install the module "Image::Magic".

Last step is to install the module.
Hopefully this will be of help:
http://www.rcbowen.com/imho/perl/modules.html

BTW, is your server a unix, windows or other server?

emin3m
11-08-2005, 05:41 PM
well its unix i think
i cant install am not owner of that hosting am just developer for that
hosting provider claims that they have image magick installed
iev asked for sample running script on your server
lets see what they come up with
can i install module on any hosting!??? am not one of hosting providers?
where ever i said my server means my webspace!, i dun own any web server ! :)

Ultimater
11-08-2005, 05:52 PM
Trust me, the module is NOT installed on your server. If you cannot install it because you are not the site admin, at least upload the module "Magick.pm" into a new directory "Images" within the directy of your PL file.

I'll even walk you through it.
1. copy all the code contained in http://search.cpan.org/src/JCRISTY/PerlMagick-6.24/Magick.pm and put it into your text editor
2. save the file as "Magick.pm" (first letter capital)
3. open your FTP
4. find the directory that contains your PL file
5. create a sub-directory within there and call it "Images"
6. open the directory called "Images"
7. upload the file "Magick.pm" from your desktop to the FTP
8. run your PL file and it should successfully locate the module.

Jeff Mott
11-08-2005, 06:05 PM
If you're curious about the original hello world problem, I would very largely bet that you are uploading your scripts in binary mode rather than text or ascii. The reason the hello world script failed is because the path to perl has to end with a new line character, and a newline in windows is not a newline in *nix.

emin3m
11-08-2005, 06:09 PM
Can't find 'boot_Image__Magick' symbol in /usr/local/lib/libMagick.so
is now the error
so i am downloading the tar.gz file and will extract it in the folder where my cgi file is
hmm ill ask where ill get stuck
thanx a lot Ultimater

emin3m
11-09-2005, 09:24 PM
path to Perl is: #!/usr/local/bin/perl
Path to Image::Magick is: /usr/bin/convert or /usr/bin/mogrify
and this is the code i want to run
how to mention image magick module path given above
#!/usr/local/bin/perl -w
#use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

print header();
print "Hello, World.";
use Image::Magick;
$image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->Write(filename=>'shared/image.png', compression=>'None');
please correct the code and let me know
adn btw while error @INC contains: /usr/local/lib/perl5/5.8.3/i386-freebsd
/usr/local/lib/perl5/5.8.3
/usr/local/lib/perl5/site_perl/5.8.3/i386-freebsd
/usr/local/lib/perl5/site_perl/5.8.3
/usr/local/lib/perl5/site_perl
means it dosent searchs the image magick paths :(

emin3m
11-10-2005, 09:54 AM
?? :(

Nedals
11-10-2005, 10:29 PM
If Image::Majick is installed in '../convert' directory, add the 'use lib..' line shown below and it should work. If you still get an error, the module is not installed. So check again with your host.

It is possible to add a module into any directory (preferably above your webroot directory) but Image::Majick, I believe, contains some 'C' files. So it might be difficult to install yourself without 'root' access.

For reference, you can install any 'all' Perl modules by simply puttting the perl source code into a directory of your choosing and adding that 'use lib...' line.

And don't edit out strict :)

#!/usr/local/bin/perl -w
use strict;
use lib "/usr/bin/convert/";
use Image::Magick;

use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

print header();
print "Hello, World.";

my $image = Image::Magick->new;
$image->Set(size=>'100x100');
$image->Write(filename=>'shared/image.png', compression=>'None');

emin3m
11-11-2005, 12:54 PM
thanx dude
but lol i removed last back slash from
use lib "/usr/bin/convert/";

this worked !
thanx a lot!