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

Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 08-11-2016
To handle the case during copy when: No space left on device

Code:
 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:

Code:
             else {         
                          system("cp -rf $from $to 2>/dev/null");
                           if ($? ne 0){
                             print "Process failed."
                           }

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

Please suggest.

The code I mentioned is the perl code .. I just missed to mention that.
# 2  
Old 08-11-2016
Hi.

Perhaps some help from:
Code:
            The return value is the exit status of the program as returned by
            the "wait" call. To get the actual exit value, shift right by
            eight (see below). See also "exec". This is not what you want to
            use to capture the output from a command; for that you should use
            merely backticks or "qx//", as described in "`STRING`" in perlop.
            Return value of -1 indicates a failure to start the program or an
            error of the wait(2) system call (inspect $! for the reason).

            If you'd like to make "system" (and many other bits of Perl) die
            on error, have a look at the autodie pragma.

-- excerpt from perldoc -f system

Best wishes ... cheers, drl
# 3  
Old 09-14-2016
Can you use File::Copy module ?

Code:
use File::Copy;
copy("sourcefile","destinationfile") or die "Copy failed: $!";

Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
No space left on device while there is plenty of space available umen Linux 3 04-23-2017 05:48 AM
To handle the case during copy when: No space left on device ambarginni Shell Programming and Scripting 1 08-11-2016 06:58 AM
Cpio: copy failed - No space left on device when I use rpm tatab355 AIX 7 06-30-2015 01:02 PM
Write to 1 failed [No space left on device] mahish20 Shell Programming and Scripting 6 03-13-2015 06:43 PM
Received error as Not enough space left on device Nishant.Jvk HP-UX 4 12-13-2013 02:44 AM
No space left on device when using rm GTCG Linux 8 08-06-2013 04:59 PM
Jenkins -- No space left on device sgffgs Ubuntu 4 11-02-2012 07:30 PM
No Space left On Device koti_rama Shell Programming and Scripting 2 06-06-2012 02:23 AM
No space left on device but free space and inodes are available... beta17 Solaris 8 09-01-2011 04:03 AM
pkgadd: errno 28: No space left on device viki250 Solaris 5 04-01-2010 01:22 PM
No space left on device mjdbouk UNIX for Dummies Questions & Answers 4 09-16-2009 05:35 AM
No space left on device atiato Solaris 3 08-06-2009 07:25 AM
No space left on device unclefab Solaris 4 09-10-2008 05:31 AM
no space left on device anjane UNIX for Advanced & Expert Users 2 02-22-2005 03:20 PM
no space left on device kristy UNIX for Dummies Questions & Answers 1 05-29-2001 10:02 AM