[ic] Usertag return value

Gert van der Spoel gert at 3edge.com
Sun Feb 15 11:42:27 UTC 2009


> -----Original Message-----
> From: interchange-users-bounces at icdevgroup.org [mailto:interchange-
> users-bounces at icdevgroup.org] On Behalf Of Grant
> Sent: Sunday, February 15, 2009 2:53 AM
> To: interchange-users at icdevgroup.org
> Subject: Re: [ic] Usertag return value
> 
> >>>>>>>>> $return= $image-
> >Write(filename=>'/file/location/'.$name.'_image.jpg')
> >>>>>>>>> or return 0;
> >>>>>>>>> $Tag->log("1: return=$return error=$!");
> >>>>>>>>> $return= chmod(0644,"/file/location/".$name."_image.jpg") or
> return 0;
> >>>>>>>>> $Tag->log("2: return=$return error=$!");
> >>>>>>>>>
> >>>>>>> Why not write it like this:
> >>>>>>>
> >>>>>>> return 0
> >>>>>>>   if ! $image-
> >Write(filename=>'/file/location/'.$name.'_image.jpg');
> >>>>>>>
> >>>>>>> return 0
> >>>>>>>   if ! chmod(0644,"/file/location/".$name."_image.jpg");
> >>>>>>>
> >>>>>> I tried this with the same results.  The first 3 commands
> execute, the
> >>>>>> last 3 commands don't execute, and the usertag exits with '0'.
> If I
> >>>>>> remove:
> >>>>>>
> >>>>>> return 0
> >>>>>>   if !
> >>>>>>
> >>>>>> everything executes, but I don't get the '0' in case of failure.
> >>>>>>
> >>>>> So, you want all commands to execute regardless and the tag to
> return 0
> >>>>> if any command fails?
> >>>>>
> >>>> Thanks Peter, but what I'm after is processing to stop and a
> return
> >>>> value of 0 in case a command fails.  The usertag executes all the
> way
> >>>> through unless I set it up to return 0 in case of failure, in
> which
> >>>> case processing stops halfway through.  I'd also like any error
> info
> >>>> to be printed to the error.log because my app needs a 1 or 0
> returned
> >>>> by the usertag.
> >>>>
> >>> Try this then:
> >>>
> >>> command1 or do {
> >>>        ::logError "Error running command1: $!";
> >>>        return 0;
> >>> }
> >>>
> >>> command2 or do {
> >>>        ::logError "Error running command2: $!";
> >>>        return 0;
> >>> }
> >>>
> >>> ...
> >>>
> >>> commandn or do {
> >>>        ::logError "Error running commandn: $!";
> >>>        return 0;
> >>> }
> >>>
> >>
> >> This is weird.  I changed it to:
> >>
> >> command or do {
> >>   ::logError "Error running command: $!";
> >>   return 0;
> >> };
> >>
> >>
> >
> > try
> > oops missed a comma....
> >
> > command or do {
> >  ::logError("Error running command: %s", $!);
> >  return 0;
> > };
> 
> I changed it to this:
> 
> chmod(0644,"/file/location/$sku.jpg") or do {
>   ::logError("create_image.tag error: %s", $!);
>   return 0;
> };
> 
> but I get the same thing in error.log:
> 
> create_image.tag error:
> 
> Any idea why this is failing to log anything?
> 
Nope no clue .... I have tested the following:

test.html: 
test<br>
[changemod]<br>
done<br>

changemod.tag:
UserTag changemod Routine <<EOR
sub {

 chmod(0644,"<CATROOT>/pages/x") or do {
    ::logError("create_image.tag error: %s", $!);
    return 0;
 };
 return 1;

}
EOR

- test.html I placed in my pages dir
- changemod.tag  I put in my usertags dir   (I have an
/opt/interchange/usertags, but I suppose you can also have it under your own
catalog).
- I had to SafeUntrap chmod

1) pages/x  does not exist, error.log:
10.0.0.152 FBCKM9U3:10.0.0.152 - [15/February/2009:12:32:30 +0100] acm
/acm/test create_image.tag error: No such file or directory

2) pages/x exists, but cannot change perms:
10.0.0.152 FBCKM9U3:10.0.0.152 - [15/February/2009:12:39:49 +0100] acm
/acm/test create_image.tag error: Operation not permitted

3) pages/x exists, and can be changed:
- permissions change and nothing in the logfile .... 

So this works .. Perhaps you can try to do the same and see if it has to do
with your environment or with something totally different in your situation.

CU,

Gert



















More information about the interchange-users mailing list