Topic "Duplicating files - cp: preserving times for - Operation not permitted"

Author Message
hrvoj3e
[View user's profile]

Joined: 2017-05-03
Posts: 2
Files have the same group and group has write permissions but I always get this error:

Quote:
Command 'cp -p -r -f "SomeFile.php" "/target/path/to/file/SomeFile.php"'
failed with return code 1 and error message
cp: preserving times for '/target/path/to/file/SomeFile.php': Operation not permitted.

Quote:
Current dir : "/source/path/to/file/SomeFile.php"
Duplicate to : "/target/path/to/file/SomeFile.php"

Stat info for both files:
Code:
  File: "/source/path/to/file/SomeFile.php"
  Size: 39981           Blocks: 80         IO Block: 4096   regular file
Device: fc01h/64513d    Inode: 659763      Links: 1
Access: (0775/-rwxrwxr-x)  Uid: ( 1003/userA)   Gid: ( 1001/ group1)

  File: "/source/path/to/file/SomeFile.php"
  Size: 39981           Blocks: 80         IO Block: 4096   regular file
Device: fc01h/64513d    Inode: 2632005     Links: 1
Access: (0775/-rwxrwxr-x)  Uid: ( 1001/ userB)   Gid: ( 1001/ group1)
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
To preserve timestamp (-p), you actually need to be a (target) file owner.

As a workaround, you can setup a custom command without the -p:
cp -r -f "!" "!?Target remote path?!"
https://winscp.net/eng/docs/custom_command
hrvoj3e
[View user's profile]

Joined: 2017-05-03
Posts: 2
How can I get the same behaviour as the native Duplicate (Shift+F5) command?
I want to auto populate the target path with the current selected file path.

cp -r -f "!" "!?Target remote path?!!"

Quote:
! Any File path (a relative path to a root of an operation, when referring to remote file; an absolute path when referring to a local temporary copy of a remote file). Command with the pattern will be executed once for every selected file. In general it should be surrounded with quotes for the command to work with filenames containing spaces. Cannot be combined with pattern !&.

Quote:
!?prompt[\]?default! Any When used, user is prompted to enter value that replaces the pattern. prompt can define a message of the prompt and default a default value, both can be empty. Special characters entered by user are automatically delimited. You can prohibit this using optional backslash (\) before second question mark (?).


Btw. how to make it work with preserving timestamps in debian/ubuntu?
Do I need to use ACL for file permissions? We use WinSCP a lot and multiple users edit the same files
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26730
Location: Prague, Czechia
hrvoj3e wrote:
How can I get the same behaviour as the native Duplicate (Shift+F5) command?
I want to auto populate the target path with the current selected file path.

That's not possible.

Another way is to alias the cp to drop the -p switch (some shell script would be required for that).

Quote:
Btw. how to make it work with preserving timestamps in debian/ubuntu?
Do I need to use ACL for file permissions? We use WinSCP a lot and multiple users edit the same files

I do not have any experience with *nix ACLs.
Advertisements

You can post new topics in this forum

Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License