Moreno, Javier (GXS, Softtek) wrote:
Hi all,

I have some code that is failing a copy when the script is running but if I do it command line it works fine. So I want to know how to troubleshoot or how to validate if a copy is being done successfully. I am appending all the results of the copy to a common file like:

if (system ("cp $source $target >>results"))
{
print "Unable to copy file $target\n"
. "Command was: cp $source $target (See results : $?)\n");
}
I would use File::Copy instead to avoid shelling out.

system returns 0 on success, else the return code left shifted 8
(see perlfunc man page for the scoop).

                $exit_value  = $? >> 8;
                $signal_num  = $? & 127;
                $dumped_core = $? & 128;

What are you getting for an error ?

You can check to see if the file was created by using stat on $target
and that should tell you if the copy worked.


--
  ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
 (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to