Sponsored Content
Full Discussion: Perl copy vs system cp
Top Forums Shell Programming and Scripting Perl copy vs system cp Post 302383885 by pludi on Friday 1st of January 2010 03:04:30 PM
Old 01-01-2010
IMO the best argument for not using a system utility if there's an equivalent Perl-based solution: portability. File::Copy will work on any system that can run Perl. cp won't work on any platform where the file duplication utility isn't called that.
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

on solaris best utility to copy a file system?

Hi, - on a solaris box what is the best utility to copy a whole file system from one place to other? - the aim of the operation is to place the contents of the whole file system to other file system within the discs cp ? - cpio? - tar? - what about file systemes containing symbolic links ?... (1 Reply)
Discussion started by: JAKEZ
1 Replies

2. Solaris

System copy with flarcreate

Hi, i'm trying to make a system copy from one server to another (solaris 9), they have the same configuration. I've tried to create a flash archive using the flarcreate but the flash file size is 5.06 approx. and the method the flarcreate is using is CPIO and he cannot handle sizes over 4 GB. Is... (2 Replies)
Discussion started by: pasalagua
2 Replies

3. Shell Programming and Scripting

copy directory structure to a system on the network

I am trying to write a script which has to copy the directory structure from my system to another system on the network. But I dont want the files to be copied. I think I have to start with copying all subdirectories names in a directory to a system on the network. Here's the case: Source... (1 Reply)
Discussion started by: firefox211
1 Replies

4. Programming

Copy a file using UNIX-system calls

#include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<stdlib.h> int main( int argc,char *argv ) { char buf; int sourcefile,destfile,n; if(argc!=3) { write(STDOUT_FILENO,"prgm1 <sourcefile> <destination file>\n",50); ... (6 Replies)
Discussion started by: c_d
6 Replies

5. UNIX for Dummies Questions & Answers

How to copy my system hdd usb stick from 4GB to 8GB ?

Hi, my router is my Linux embedded device. I have system installed on HDD 4GB usb stick, part1 swap, part2 /opt , part3 data. I need to copy my system to new HDD 8GB usb stick. What is a way for 4GB > 4GB HDD and what for 4GB > 8GB As I remeber, I can copy image of my 4GB HDD usb stick... (7 Replies)
Discussion started by: jack2
7 Replies

6. Shell Programming and Scripting

File Copy Perl

Hi Could you please help me on this I have folder called D:\Data in which we have 20 files coming daily and needed all 20 files to copy into D:\Target ,as i am new to PERL, i did nt know how to use this I googled sme of the code and done the copy script,it is throwing error like we do... (1 Reply)
Discussion started by: vaas
1 Replies

7. AIX

Copy huge files system

Dear Guy’s By using dd command or any strong command, I’d like to copy huge data from file system to another file system Sours File system: /sfsapp File system has 250 GB of data Target File system: /tgtapp I’d like to copy all these files and directories from /sfsapp to /tgtapp as... (28 Replies)
Discussion started by: Mr.AIX
28 Replies

8. UNIX for Advanced & Expert Users

Grub - how to boot a copy of Linux (full system backup)

Hi All, I have successfully backup & restore (using tar) one of my Debian Lenny Servers. On the restore server (standby machine), everytime i have to erase the disk & extract the tar backup. I want to extract the tar on the running restore server on a directory for e.g /systembackup-01,... (11 Replies)
Discussion started by: coolatt
11 Replies

9. Shell Programming and Scripting

Copy files with pattern from ext4 to cifs file system

Hi I have a shell script to copy a pattern of files from Linux to Windows Filesystem. When i execute the below command cp -av TOUT_05-02-13* Windows/Folder `TOUT_05-02-13-19:02:37.tar.gz' -> `Windows/Folder/SYSOUT_05-02-13-19:02:37.tar.gz' cp: cannot create regular file... (5 Replies)
Discussion started by: rakeshkumar
5 Replies

10. Solaris

Basic question regarding root file system copy to another disk

Hello, I am creating a new disk using the following command: dd if=/dev/zero of=/export/home/ramdisk/0 bs=512 count=4096k after creating the disk, i tool a ufsdump of a solaris 10 filesytem (disk size 512MB) ufsdump -cvf /export/home/ufsdump/sol_orig /and then restored the dump files onto... (10 Replies)
Discussion started by: Zam_1234
10 Replies
File::Copy(3pm) 					 Perl Programmers Reference Guide					   File::Copy(3pm)

NAME
File::Copy - Copy files or filehandles SYNOPSIS
use File::Copy; copy("file1","file2") or die "Copy failed: $!"; copy("Copy.pm",*STDOUT); move("/dev1/fileA","/dev2/fileB"); use File::Copy "cp"; $n = FileHandle->new("/a/file","r"); cp($n,"x"); DESCRIPTION
The File::Copy module provides two basic functions, "copy" and "move", which are useful for getting the contents of a file from one place to another. copy The "copy" function takes two parameters: a file to copy from and a file to copy to. Either argument may be a string, a FileHandle reference or a FileHandle glob. Obviously, if the first argument is a filehandle of some sort, it will be read from, and if it is a file name it will be opened for reading. Likewise, the second argument will be written to (and created if need be). Trying to copy a file on top of itself is a fatal error. If the destination (second argument) already exists and is a directory, and the source (first argument) is not a filehandle, then the source file will be copied into the directory specified by the destination, using the same base name as the source file. It's a failure to have a filehandle as the source when the destination is a directory. Note that passing in files as handles instead of names may lead to loss of information on some operating systems; it is recommended that you use file names whenever possible. Files are opened in binary mode where applicable. To get a consistent behaviour when copying from a filehandle to a file, use "binmode" on the filehandle. An optional third parameter can be used to specify the buffer size used for copying. This is the number of bytes from the first file, that will be held in memory at any given time, before being written to the second file. The default buffer size depends upon the file, but will generally be the whole file (up to 2MB), or 1k for filehandles that do not reference files (eg. sockets). You may use the syntax "use File::Copy "cp"" to get at the "cp" alias for this function. The syntax is exactly the same. The behavior is nearly the same as well: as of version 2.15, <cp> will preserve the source file's permission bits like the shell utility cp(1) would do, while "copy" uses the default permissions for the target file (which may depend on the process' "umask", file ownership, inherited ACLs, etc.). If an error occurs in setting permissions, "cp" will return 0, regardless of whether the file was successfully copied. move The "move" function also takes two parameters: the current name and the intended name of the file to be moved. If the destination already exists and is a directory, and the source is not a directory, then the source file will be renamed into the directory specified by the destination. If possible, move() will simply rename the file. Otherwise, it copies the file to the new location and deletes the original. If an error occurs during this copy-and-delete process, you may be left with a (possibly partial) copy of the file under the destination name. You may use the "mv" alias for this function in the same way that you may use the <cp> alias for "copy". syscopy File::Copy also provides the "syscopy" routine, which copies the file specified in the first parameter to the file specified in the second parameter, preserving OS-specific attributes and file structure. For Unix systems, this is equivalent to the simple "copy" routine, which doesn't preserve OS-specific attributes. For VMS systems, this calls the "rmscopy" routine (see below). For OS/2 systems, this calls the "syscopy" XSUB directly. For Win32 systems, this calls "Win32::CopyFile". Special behaviour if "syscopy" is defined (OS/2, VMS and Win32): If both arguments to "copy" are not file handles, then "copy" will perform a "system copy" of the input file to a new output file, in order to preserve file attributes, indexed file structure, etc. The buffer size parameter is ignored. If either argument to "copy" is a handle to an opened file, then data is copied using Perl operators, and no effort is made to preserve file attributes or record structure. The system copy routine may also be called directly under VMS and OS/2 as "File::Copy::syscopy" (or under VMS as "File::Copy::rmscopy", which is the routine that does the actual work for syscopy). rmscopy($from,$to[,$date_flag]) The first and second arguments may be strings, typeglobs, typeglob references, or objects inheriting from IO::Handle; they are used in all cases to obtain the filespec of the input and output files, respectively. The name and type of the input file are used as defaults for the output file, if necessary. A new version of the output file is always created, which inherits the structure and RMS attributes of the input file, except for owner and protections (and possibly timestamps; see below). All data from the input file is copied to the output file; if either of the first two parameters to "rmscopy" is a file handle, its position is unchanged. (Note that this means a file handle pointing to the output file will be associated with an old version of that file after "rmscopy" returns, not the newly created version.) The third parameter is an integer flag, which tells "rmscopy" how to handle timestamps. If it is < 0, none of the input file's timestamps are propagated to the output file. If it is > 0, then it is interpreted as a bitmask: if bit 0 (the LSB) is set, then timestamps other than the revision date are propagated; if bit 1 is set, the revision date is propagated. If the third parameter to "rmscopy" is 0, then it behaves much like the DCL COPY command: if the name or type of the output file was explicitly specified, then no timestamps are propagated, but if they were taken implicitly from the input filespec, then all timestamps other than the revision date are propagated. If this parameter is not supplied, it defaults to 0. Like "copy", "rmscopy" returns 1 on success. If an error occurs, it sets $!, deletes the output file, and returns 0. RETURN
All functions return 1 on success, 0 on failure. $! will be set if an error was encountered. AUTHOR
File::Copy was written by Aaron Sherman <ajs@ajs.com> in 1995, and updated by Charles Bailey <bailey@newman.upenn.edu> in 1996. perl v5.16.2 2012-10-25 File::Copy(3pm)
All times are GMT -4. The time now is 10:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy