To handle the case during copy when: No space left on device

 print "After create SubDir routine.";
                  createSubDirs($fileDir);
                        my $from = $ORACLE_HOME.$dirSep.$file;
                        my $to = $bootstrapDir.$dirSep.$fileDir;
                        if ($isWindows)  {
                           copy($from, $to);
                        } else {                        
                          system("cp -rf $from $to");                           
                        }
                        print "\nCopied file $from to $to\n";

In the above code I wanted to handle the case that during copy when: No space left on device it should not keep listing error for every file to the user that: " No space left on device" either it should just gracefully come out saying the "Process Failed."

then I manipulated the code like:

else {
                          print "I am here d";
                          system("cp -rf $from $to 2>/dev/null");
                           if ($? ne 0){
                             print "Bootstrap failed."
                           }

but it seems the return code is still returning code as 0 and I still could not trap the error.

Please suggest.

---------- Post updated at 03:19 PM ---------- Previous update was at 12:21 PM ----------

The code I mentioned is the perl code .. I just missed to mention that.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.