From: Jamie C. <jca...@we...> - 2001-05-20 15:06:47
|
Joe Cooper wrote: > > Hi Jamie, > > I've begun to implement DNS record creation using remote_foreign_call, > and in an attempt to code 'correctly' from the beginning, I'm trying to > figure out how to do error checking, or at least some form of > success/fail checking on the remote call. > > Any pointers on how this should be done? I see that the create_record > routine (and pretty much all the rest) don't return anything > explicitly...So I'm guessing this is one of those things that perl > probably does implicitly in some magical manner, but I'm not real sure > where to look to figure out the magic. > > So, my question is: Can I check for success/fail on a > remote_foreign_call? If so, how? There are really 2 kinds of failure that you need to check for - failure to connect to the remote server, and failure of the remote function. In the first case, the &remote_foreign_call function will call perl's die statement if anything goes wrong, which will usually cause your script to exit. To trap this, use eval like so : $rv = eval { &remote_foreign_call(....) } if ($@) { # failed to connect or login to the remote webmin server } The second thing you might need to check for is the return value of the remote function, which will just be returned by &remote_foreign_call . Though in the case you mentioned above (DNS record creation) there is no meaningful return value even if the DNS record wasn't saved for some reason, such as a lack of disk space. - Jamie |