register in perl scripts
Message-ID:<gofoj8$nod$1@aioe.org>
Subject:
"register" (in perl scripts)
Date:Mon, 2 Mar 2009 04:51:19 +0100
Posted this on comp.graphics.apps.gimp and will duplicate it here if I
may, with some additional info. I use (often perl generated) web pages
as fronts for my own utilities. They all work except one involving
scripted gimp. Would backleveling to an earlier perl-5.x help
(probably a bad idea)?
.....................................
This one-liner used to work in some old scripts I've dug up but
doesn't anymore.
register "", "", "", "", "", "", "<None>", "*", "",
So I tried a short scriptlet from
http://www.gimp.org/tutorials/Basic_Perl/
renamed it test.pl with the beginning changed as shown to make the
modules load ...but it doesn't work either. Gets me the apache errors
shown below. Is it necessary to register at all if I only need the
gimp calls in scripts (not while using gimp normally)?
When does gimp have to be running, if?
TIA
-------------------------------------------------------
#!/usr/local/bin/perl -w
# next 2 lines replaced
# use Gimp ":auto";
# use Gimp::Fu;
# with the next 2 lines (don't know how this affects ":auto")
use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi';
use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi/Gimp';
sub img_uni {
my ($size, $color) = @_;
# Create a new image
$img = gimp_image_new($size, $size, RGB);
# Create a new layer
$layer = gimp_layer_new($img, $size, $size, RGB,
"Layer 1", 100, NORMAL_MODE);
# add the layer to the image
gimp_image_add_layer($img, $layer, -1);
# Set the background to the required color
gimp_palette_set_background($color);
# Paint the layer
gimp_edit_fill($layer, BG_IMAGE_FILL);
# Return the image
return $img;
}
register
"img_uni", # fill in name
"Create a uniform image", # a small description
"A tutorial script", # a help text
"Dov Grobgeld", # Your name
"Dov Grobgeld (c)", # Your copyright
"1999-05-14", # Date
"<Toolbox>/Xtns/Perl-Fu/Tutorial/Img Uni", # menu path
"",
[
[PF_INT, "size", "Img size", 100],
[PF_COLOR, "color", "Img color", [255,127,0]]
],
\&img_uni;
exit main();
-----------------------------------------------------------------
[error] [client 127.0.0.1] Unquoted string "register" may clash with
future reserved word at /srv/www/htdocs/user/cgi-bin/test.pl line 24.,
referer: http://127.0.0.1/
[error] [client 127.0.0.1] String found where operator expected at
/srv/www/htdocs/user/cgi-bin/test.pl line 24, near "register, referer:
http://127.0.0.1/
[error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
[error] [client 127.0.0.1] \t(Do you need to predeclare register?),
referer: http://127.0.0.1/
[error] [client 127.0.0.1] syntax error at
/srv/www/htdocs/user/cgi-bin/magi/test.pl line 24, near "register,
referer: http://127.0.0.1/
[error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
[error] [client 127.0.0.1] Execution of
/srv/www/htdocs/user/cgi-bin/test.pl aborted due to compilation
errors., referer: http://127.0.0.1/
[error] [client 127.0.0.1] Premature end of script headers: test.pl,
referer: http://127.0.0.1/
-----------------------------------------------------------------
Message-ID:<8bdb5$49ac0311$414ebc3d$25007@EVERESTKC.NET>
Subject:
Re: "register" (in perl scripts)
Date:Mon, 2 Mar 2009 17:02:24 +0100
On 03/01/09 19:51, rsink wrote:
> Posted this on comp.graphics.apps.gimp and will duplicate it here if I
> may, with some additional info. I use (often perl generated) web pages
> as fronts for my own utilities. They all work except one involving
> scripted gimp. Would backleveling to an earlier perl-5.x help
> (probably a bad idea)?
>
> .....................................
> This one-liner used to work in some old scripts I've dug up but
> doesn't anymore.
>
> register "", "", "", "", "", "", "<None>", "*", "",
>
> So I tried a short scriptlet from
>
> http://www.gimp.org/tutorials/Basic_Perl/
>
> renamed it test.pl with the beginning changed as shown to make the
> modules load ...but it doesn't work either. Gets me the apache errors
> shown below. Is it necessary to register at all if I only need the
> gimp calls in scripts (not while using gimp normally)?
>
> When does gimp have to be running, if?
>
> TIA
This is a Perl problem, not a GIMP problem so you would probably
have much better luck on a Perl help forum.
However, it looks to me like you're trying to execute a command
that is external to perl, is that true? In other words, can you
run the 'register' command from the command shell?
If that is the case, you can't just reference the external command
in perl the way you have. Here is an example of one way to do it
(there are more...):
@args = ("command", "arg1", "arg2", "arg3", ...);
if ( system(@args) == 0 )
{
print "The command worked!\n";
}
else
{
print "The command failed: $!\n";
}
Where 'command' is the command you wish to execute ("register" in
this case) and "arg1", etc. are the command-line arguments.
If 'register' is supposed to be a Perl subroutine, then perhaps it
used to be defined by one of the Gimp libraries you're "use"ing, but
is no longer?
Again, someone who knows more about Perl may be able to help you get
to the bottom of that.
By the way, your script doesn't appear to use any CGI, etc. - at
least not at this point, so you don't need to call it from your web
service. You can test it by calling the script directly from the
command shell (assuming the script is marked as executable).
Best Regards,
>
> -------------------------------------------------------
> #!/usr/local/bin/perl -w
>
> # next 2 lines replaced
> # use Gimp ":auto";
> # use Gimp::Fu;
> # with the next 2 lines (don't know how this affects ":auto")
>
> use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi';
> use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi/Gimp';
>
> sub img_uni {
> my ($size, $color) = @_;
> # Create a new image
> $img = gimp_image_new($size, $size, RGB);
> # Create a new layer
> $layer = gimp_layer_new($img, $size, $size, RGB,
> "Layer 1", 100, NORMAL_MODE);
> # add the layer to the image
> gimp_image_add_layer($img, $layer, -1);
> # Set the background to the required color
> gimp_palette_set_background($color);
> # Paint the layer
> gimp_edit_fill($layer, BG_IMAGE_FILL);
> # Return the image
> return $img;
> }
> register
> "img_uni", # fill in name
> "Create a uniform image", # a small description
> "A tutorial script", # a help text
> "Dov Grobgeld", # Your name
> "Dov Grobgeld (c)", # Your copyright
> "1999-05-14", # Date
> "<Toolbox>/Xtns/Perl-Fu/Tutorial/Img Uni", # menu path
> "",
> [
> [PF_INT, "size", "Img size", 100],
> [PF_COLOR, "color", "Img color", [255,127,0]]
> ],
> \&img_uni;
> exit main();
>
> -----------------------------------------------------------------
>
> [error] [client 127.0.0.1] Unquoted string "register" may clash with
> future reserved word at /srv/www/htdocs/user/cgi-bin/test.pl line 24.,
> referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] String found where operator expected at
> /srv/www/htdocs/user/cgi-bin/test.pl line 24, near "register, referer:
> http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] \t(Do you need to predeclare register?),
> referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] syntax error at
> /srv/www/htdocs/user/cgi-bin/magi/test.pl line 24, near "register,
> referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] Execution of
> /srv/www/htdocs/user/cgi-bin/test.pl aborted due to compilation
> errors., referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] Premature end of script headers: test.pl,
> referer: http://127.0.0.1/
>
> -----------------------------------------------------------------
>
Message-ID:<golacl$5t9$2@aioe.org>
Subject:
Re: "register" (in perl scripts)
Date:Wed, 4 Mar 2009 08:25:41 +0100
Mark Hansen wrote:
> ...
> This is a Perl problem, not a GIMP problem so you would probably
> have much better luck on a Perl help forum.
Agreed, in part. I was going to post this 2nd version on
perl.beginners but forgot to change the group name. When I saw the
goof I cancelled the posting and repeated using the perl group
instead. The posting then showed up there leaving the original version
here. Today however, the perl posting has vanished. Sorry about all
this. I'll see if I can start all over on perl.beginners. Thanks for
the response.
> However, it looks to me like you're trying to execute a command
> that is external to perl, is that true? In other words, can you
> run the 'register' command from the command shell?
>
> If that is the case, you can't just reference the external command
> in perl the way you have. Here is an example of one way to do it
> (there are more...):
>
> @args = ("command", "arg1", "arg2", "arg3", ...);
> if ( system(@args) == 0 )
> {
> print "The command worked!\n";
> }
> else
> {
> print "The command failed: $!\n";
> }
>
> Where 'command' is the command you wish to execute ("register" in
> this case) and "arg1", etc. are the command-line arguments.
Tried it, from command line too, but the same syntax errors show.
> If 'register' is supposed to be a Perl subroutine, then perhaps it
> used to be defined by one of the Gimp libraries you're "use"ing, but
> is no longer?
That could be. If anyone using gimp-2.6.5 and perl-5.10 has been able
to run scripted gimp I'd appreciate a simple sample (and setup steps)
to at least start off with a known working base.
Message-ID:<gofoj8$nod$1@aioe.org>
Subject:
"register" (in perl scripts)
Date:Mon, 2 Mar 2009 04:51:19 +0100
Posted this on comp.graphics.apps.gimp and will duplicate it here if I
may, with some additional info. I use (often perl generated) web pages
as fronts for my own utilities. They all work except one involving
scripted gimp. Would backleveling to an earlier perl-5.x help
(probably a bad idea)?
.....................................
This one-liner used to work in some old scripts I've dug up but
doesn't anymore.
register "", "", "", "", "", "", "<None>", "*", "",
So I tried a short scriptlet from
http://www.gimp.org/tutorials/Basic_Perl/
renamed it test.pl with the beginning changed as shown to make the
modules load ...but it doesn't work either. Gets me the apache errors
shown below. Is it necessary to register at all if I only need the
gimp calls in scripts (not while using gimp normally)?
When does gimp have to be running, if?
TIA
-------------------------------------------------------
#!/usr/local/bin/perl -w
# next 2 lines replaced
# use Gimp ":auto";
# use Gimp::Fu;
# with the next 2 lines (don't know how this affects ":auto")
use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi';
use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi/Gimp';
sub img_uni {
my ($size, $color) = @_;
# Create a new image
$img = gimp_image_new($size, $size, RGB);
# Create a new layer
$layer = gimp_layer_new($img, $size, $size, RGB,
"Layer 1", 100, NORMAL_MODE);
# add the layer to the image
gimp_image_add_layer($img, $layer, -1);
# Set the background to the required color
gimp_palette_set_background($color);
# Paint the layer
gimp_edit_fill($layer, BG_IMAGE_FILL);
# Return the image
return $img;
}
register
"img_uni", # fill in name
"Create a uniform image", # a small description
"A tutorial script", # a help text
"Dov Grobgeld", # Your name
"Dov Grobgeld (c)", # Your copyright
"1999-05-14", # Date
"<Toolbox>/Xtns/Perl-Fu/Tutorial/Img Uni", # menu path
"",
[
[PF_INT, "size", "Img size", 100],
[PF_COLOR, "color", "Img color", [255,127,0]]
],
\&img_uni;
exit main();
-----------------------------------------------------------------
[error] [client 127.0.0.1] Unquoted string "register" may clash with
future reserved word at /srv/www/htdocs/user/cgi-bin/test.pl line 24.,
referer: http://127.0.0.1/
[error] [client 127.0.0.1] String found where operator expected at
/srv/www/htdocs/user/cgi-bin/test.pl line 24, near "register, referer:
http://127.0.0.1/
[error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
[error] [client 127.0.0.1] \t(Do you need to predeclare register?),
referer: http://127.0.0.1/
[error] [client 127.0.0.1] syntax error at
/srv/www/htdocs/user/cgi-bin/magi/test.pl line 24, near "register,
referer: http://127.0.0.1/
[error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
[error] [client 127.0.0.1] Execution of
/srv/www/htdocs/user/cgi-bin/test.pl aborted due to compilation
errors., referer: http://127.0.0.1/
[error] [client 127.0.0.1] Premature end of script headers: test.pl,
referer: http://127.0.0.1/
-----------------------------------------------------------------
Message-ID:<8bdb5$49ac0311$414ebc3d$25007@EVERESTKC.NET>
Subject:
Re: "register" (in perl scripts)
Date:Mon, 2 Mar 2009 17:02:24 +0100
On 03/01/09 19:51, rsink wrote:
> Posted this on comp.graphics.apps.gimp and will duplicate it here if I
> may, with some additional info. I use (often perl generated) web pages
> as fronts for my own utilities. They all work except one involving
> scripted gimp. Would backleveling to an earlier perl-5.x help
> (probably a bad idea)?
>
> .....................................
> This one-liner used to work in some old scripts I've dug up but
> doesn't anymore.
>
> register "", "", "", "", "", "", "<None>", "*", "",
>
> So I tried a short scriptlet from
>
> http://www.gimp.org/tutorials/Basic_Perl/
>
> renamed it test.pl with the beginning changed as shown to make the
> modules load ...but it doesn't work either. Gets me the apache errors
> shown below. Is it necessary to register at all if I only need the
> gimp calls in scripts (not while using gimp normally)?
>
> When does gimp have to be running, if?
>
> TIA
This is a Perl problem, not a GIMP problem so you would probably
have much better luck on a Perl help forum.
However, it looks to me like you're trying to execute a command
that is external to perl, is that true? In other words, can you
run the 'register' command from the command shell?
If that is the case, you can't just reference the external command
in perl the way you have. Here is an example of one way to do it
(there are more...):
@args = ("command", "arg1", "arg2", "arg3", ...);
if ( system(@args) == 0 )
{
print "The command worked!\n";
}
else
{
print "The command failed: $!\n";
}
Where 'command' is the command you wish to execute ("register" in
this case) and "arg1", etc. are the command-line arguments.
If 'register' is supposed to be a Perl subroutine, then perhaps it
used to be defined by one of the Gimp libraries you're "use"ing, but
is no longer?
Again, someone who knows more about Perl may be able to help you get
to the bottom of that.
By the way, your script doesn't appear to use any CGI, etc. - at
least not at this point, so you don't need to call it from your web
service. You can test it by calling the script directly from the
command shell (assuming the script is marked as executable).
Best Regards,
>
> -------------------------------------------------------
> #!/usr/local/bin/perl -w
>
> # next 2 lines replaced
> # use Gimp ":auto";
> # use Gimp::Fu;
> # with the next 2 lines (don't know how this affects ":auto")
>
> use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi';
> use lib '/usr/lib/perl5/site_perl/5.10.0/i586-linux-thread-multi/Gimp';
>
> sub img_uni {
> my ($size, $color) = @_;
> # Create a new image
> $img = gimp_image_new($size, $size, RGB);
> # Create a new layer
> $layer = gimp_layer_new($img, $size, $size, RGB,
> "Layer 1", 100, NORMAL_MODE);
> # add the layer to the image
> gimp_image_add_layer($img, $layer, -1);
> # Set the background to the required color
> gimp_palette_set_background($color);
> # Paint the layer
> gimp_edit_fill($layer, BG_IMAGE_FILL);
> # Return the image
> return $img;
> }
> register
> "img_uni", # fill in name
> "Create a uniform image", # a small description
> "A tutorial script", # a help text
> "Dov Grobgeld", # Your name
> "Dov Grobgeld (c)", # Your copyright
> "1999-05-14", # Date
> "<Toolbox>/Xtns/Perl-Fu/Tutorial/Img Uni", # menu path
> "",
> [
> [PF_INT, "size", "Img size", 100],
> [PF_COLOR, "color", "Img color", [255,127,0]]
> ],
> \&img_uni;
> exit main();
>
> -----------------------------------------------------------------
>
> [error] [client 127.0.0.1] Unquoted string "register" may clash with
> future reserved word at /srv/www/htdocs/user/cgi-bin/test.pl line 24.,
> referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] String found where operator expected at
> /srv/www/htdocs/user/cgi-bin/test.pl line 24, near "register, referer:
> http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] \t(Do you need to predeclare register?),
> referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] syntax error at
> /srv/www/htdocs/user/cgi-bin/magi/test.pl line 24, near "register,
> referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] "img_uni"", referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] Execution of
> /srv/www/htdocs/user/cgi-bin/test.pl aborted due to compilation
> errors., referer: http://127.0.0.1/
>
>
> [error] [client 127.0.0.1] Premature end of script headers: test.pl,
> referer: http://127.0.0.1/
>
> -----------------------------------------------------------------
>
Message-ID:<golacl$5t9$2@aioe.org>
Subject:
Re: "register" (in perl scripts)
Date:Wed, 4 Mar 2009 08:25:41 +0100
Mark Hansen wrote:
> ...
> This is a Perl problem, not a GIMP problem so you would probably
> have much better luck on a Perl help forum.
Agreed, in part. I was going to post this 2nd version on
perl.beginners but forgot to change the group name. When I saw the
goof I cancelled the posting and repeated using the perl group
instead. The posting then showed up there leaving the original version
here. Today however, the perl posting has vanished. Sorry about all
this. I'll see if I can start all over on perl.beginners. Thanks for
the response.
> However, it looks to me like you're trying to execute a command
> that is external to perl, is that true? In other words, can you
> run the 'register' command from the command shell?
>
> If that is the case, you can't just reference the external command
> in perl the way you have. Here is an example of one way to do it
> (there are more...):
>
> @args = ("command", "arg1", "arg2", "arg3", ...);
> if ( system(@args) == 0 )
> {
> print "The command worked!\n";
> }
> else
> {
> print "The command failed: $!\n";
> }
>
> Where 'command' is the command you wish to execute ("register" in
> this case) and "arg1", etc. are the command-line arguments.
Tried it, from command line too, but the same syntax errors show.
> If 'register' is supposed to be a Perl subroutine, then perhaps it
> used to be defined by one of the Gimp libraries you're "use"ing, but
> is no longer?
That could be. If anyone using gimp-2.6.5 and perl-5.10 has been able
to run scripted gimp I'd appreciate a simple sample (and setup steps)
to at least start off with a known working base.



RSS News Feed