catching errors with galleryadd.pl

vauneen

Joined: 2005-10-14
Posts: 8
Posted: Thu, 2006-01-05 08:47

i'm trying to catch errors when using galleryadd.pl.
i've written it into a php function:

function doAddImage($imgname,$AID,$uName, $pword, $ftpdir ){
exec("perl C:/perl/galleryadd.pl -G2 -g http://my.server.net -u ".$uName." -p ".$pword." -a ".$AID." ".$ftpdir .$imgname.""); # *** vauneen
}

(i dont know perl)
i guess it's about catching what ever errors the php function exec generates.
any help appreciated,
vauneen

 
mobiGeek

Joined: 2003-10-28
Posts: 5
Posted: Tue, 2006-02-07 04:04

Depends on what you mean by "errors". Looking briefly at the script for my first time, I see that it calls die() only if it cannot open its log file and it calls exit(1) in the event of a bunch of error conditions [actually, it calls PrintErr() which does an exit(1)].

So what you want to do in PHP is to check the result of the exec() call and see if the return code is 0 (i.e. no error) or non-zero (i.e. some kind of error). You'll need to look at the PHP documentation to figure out how to handle the exit code from an exec() call.

But, one thing to note is that if you know PHP coding, then you should be able to get the gist of this perl script. It is pretty straight forward and uses an "old school" perl style.

Hope this helps,
mG.