Sponsored Content
Top Forums Shell Programming and Scripting Error on script to copy files Post 302807619 by fretagi on Wednesday 15th of May 2013 04:41:54 AM
Old 05-15-2013
Error on script to copy files

I just want to copy files and preserve the permissions
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

copy files without password in script

1. I wrote a ftp code to copy a file from unix box to another unix box. But it has clear text password in the code. Due to security constraints, clear text password in the code is not allowed. Please let me know the ways to write the code without prompting for password. 2. I tried writing scp... (0 Replies)
Discussion started by: jwala
0 Replies

2. Shell Programming and Scripting

Trying to copy a TON of files with a script

Ok, here's the problem. I need to copy about 200 GB from an old FreeBSD (5.2.1) server to a new Debian server. The old server's fastest port is the ethernet port. I set up an NFS server on the new machine so I can just copy the files over using regular commands/scripts etc. Thing is, I probably... (4 Replies)
Discussion started by: davidstvz
4 Replies

3. Shell Programming and Scripting

Need a script to copy files and check

Hi all, I need a script in ksh: 1: Copy files from directory (A) to directory (B) 2: Check if files that will be copied in directory (A) have never been yet copied to (B) 3: Never copy the last created file of directory (A) This script will run on crontab. Thanks in advance for your... (1 Reply)
Discussion started by: Camaro
1 Replies

4. Shell Programming and Scripting

error in sh script while copy files to a backup directory

I am trying to copy files from one directory to another using shell script. Can anyone please troubleshoot the code. thanks in advance... #!C:\Shell\sh.exe files_dir="C:\Documents and Settings\scripts\files" backup_dir="C:\Documents and Settings\scripts\ztest" echo cding to... (2 Replies)
Discussion started by: sureshcisco
2 Replies

5. Shell Programming and Scripting

Script to Poll Directory and Copy files

Hi all, I'm looking for a script to poll a specified directory and copy new files to another location. The script should only copy new files so, I based on mtime I guess? Can anyone point me in the right direction of a script which could do this? My scripting skills aren't too bad, but... (1 Reply)
Discussion started by: JayC89
1 Replies

6. Shell Programming and Scripting

bash script to copy files

hey everyone, new here i have arch setup and i am using smbnetfs to mount some windows shares in /mnt/smbnet what i want to do is copy files from my home dir to a dir in /mnt/smbnet but i also need it to remove files if i have deleted them from my home dir seems that cp would be the... (8 Replies)
Discussion started by: dodgefan67
8 Replies

7. Shell Programming and Scripting

Copy Files with script

Hello, I have written a script to copy files from one partion to another. Not sure if this is correct. #!/bin/sh CDR_SOURCE=/storage/archive/logmgmt/result/billing/ CDR_DEST=/storage4/archive/logmgmt/result/billing/ cp $CDR_SOURCE $CDR_DEST; exit 0 The CDR_SOURCE folder has... (5 Replies)
Discussion started by: Siddheshk
5 Replies

8. UNIX for Dummies Questions & Answers

Script to copy files from a certain date

I need to copy files from a directory that has a lot of files in it. However I only want to copy them from a certain date. My thoughts so far are to use ls -l and to pipe this into awk and print out tokens 6 (month)and 7 (day). $ ls -l -rw-r--r-- 1 prodqual tst 681883 Jun 12... (2 Replies)
Discussion started by: millsy5
2 Replies

9. UNIX for Dummies Questions & Answers

Script to search and copy files

HI everyone, I been to this site before for help and found my answers on other threads now I am posting my own :). I have a list of file names with out extensions on an txt file. I need a way for the script to search on the server for each file name and copy the files over to a new directory.... (12 Replies)
Discussion started by: sergiol
12 Replies

10. UNIX for Dummies Questions & Answers

scp error while trying to copy files

Hi, I am trying to copy files from one server to other using the below code. scp -B -p user@remoteserver:/tmp/abc.txt /landing/files The above command is failing with error You're not allowed to run 'scp -p -f /tmp/abc.txt ' When I am using scp -B -p , why am I getting error msg as scp... (2 Replies)
Discussion started by: Nikhath
2 Replies
CP(1)							    BSD General Commands Manual 						     CP(1)

NAME
cp -- copy files SYNOPSIS
cp [-R [-H | -L | -P]] [-f | -i] [-alNpv] source_file target_file cp [-R [-H | -L | -P]] [-f | -i] [-alNpv] source_file ... target_directory DESCRIPTION
In the first synopsis form, the cp utility copies the contents of the source_file to the target_file. In the second synopsis form, the con- tents of each named source_file is copied to the destination target_directory. The names of the files themselves are not changed. If cp detects an attempt to copy a file to itself, the copy will fail. The following options are available: -a Archive mode. Same as -RpP. -f For each existing destination pathname, attempt to overwrite it. If permissions do not allow copy to succeed, remove it and create a new file, without prompting for confirmation. (The -i option is ignored if the -f option is specified.) -H If the -R option is specified, symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed.) -i Causes cp to write a prompt to the standard error output before copying a file that would overwrite an existing file. If the response from the standard input begins with the character 'y', the file copy is attempted. -L If the -R option is specified, all symbolic links are followed. -l Create hard links to regular files in a hierarchy instead of copying. -N When used with -p, don't copy file flags. -P No symbolic links are followed. This is the default. -p Causes cp to preserve in the copy as many of the modification time, access time, file flags, file mode, user ID, group ID, and extended attributes, as allowed by permissions. If the user ID and group ID cannot be preserved, no error message is displayed and the exit value is not altered. If the source file has its set user ID bit on and the user ID cannot be preserved, the set user ID bit is not preserved in the copy's permissions. If the source file has its set group ID bit on and the group ID cannot be preserved, the set group ID bit is not pre- served in the copy's permissions. If the source file has both its set user ID and set group ID bits on, and either the user ID or group ID cannot be preserved, neither the set user ID or set group ID bits are preserved in the copy's permissions. Extended attributes from all accessible namespaces are copied; others are ignored. If an error occurs during this copy, a message is displayed and cp skips the other extended attributes for that file. -R If source_file designates a directory, cp copies the directory and the entire subtree connected at that point. This option also causes symbolic links to be copied, rather than followed, and for cp to create special files rather than copying them as normal files. Cre- ated directories have the same mode as the corresponding source directory, unmodified by the process's umask. -v Cause cp to be verbose, showing files as they are copied. For each destination file that already exists, its contents are overwritten if permissions allow, but its mode, user ID, and group ID are unchanged. In the second synopsis form, target_directory must exist unless there is only one named source_file which is a directory and the -R flag is specified. If the destination file does not exist, the mode of the source file is used as modified by the file mode creation mask (umask, see csh(1)). If the source file has its set user ID bit on, that bit is removed unless both the source file and the destination file are owned by the same user. If the source file has its set group ID bit on, that bit is removed unless both the source file and the destination file are in the same group and the user is a member of that group. If both the set user ID and set group ID bits are set, all of the above conditions must be fulfilled or both bits are removed. Appropriate permissions are required for file creation or overwriting. Symbolic links are always followed unless the -R flag is set, in which case symbolic links are not followed, by default. The -H or -L flags (in conjunction with the -R flag), as well as the -P flag cause symbolic links to be followed as described above. The -H and -L options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified. EXIT STATUS
The cp utility exits 0 on success, and >0 if an error occurs. COMPATIBILITY
Historic versions of the cp utility had a -r option. This implementation supports that option, however, its use is strongly discouraged, as it does not correctly copy special files, symbolic links or fifo's. SEE ALSO
mv(1), rcp(1), umask(2), fts(3), symlink(7) STANDARDS
The cp utility is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible. The -a and -l flags are non-standard extensions. They are intended to be compatible with the same options which other implementations, namely GNU coreutils and FreeBSD, of this utility have. The -v option is an extension to IEEE Std 1003.2 (``POSIX.2''). BSD
August 3, 2011 BSD
All times are GMT -4. The time now is 01:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy