What's new

FYI: WinSCP may work incorrectly when using the standard Busybox 'cp'.

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Twiglets

Senior Member
I have logged an issue with WinSCP Support to try to resolve an issue where WinSCP does not copy files correctly when performing a 'Duplicate' action on a RT-AC56U running Asuswrt-Merlin 384.5.
See https://winscp.net/forum/viewtopic.php?p=84940#84940

It looks like the issue is that the Busybox 'cp' command is not compatible with the commandline used by WinSCP.
I have been able to solve it by installing cp from the 'coreutils. (opkg install coreutils-cp).
This installs a 'cp' that is compatible with the commandline used by WinSCP.

This is a 'heads Up' in case someone else has the same problem or has not noticed the problem.

The issue is still being looked at BUT I doubt WinSCP will change just to handle a problem on a router when there is a workaround to solve it and WinSCP works everywhere else.

Likewise, I do not expect the Busybox 'cp' will be changed just because WinSCP has a problem.
 
If you’re using Windows 10, probably more convenient to use the built-in OpenSSH client including scp.exe
 
If you’re using Windows 10, probably more convenient to use the built-in OpenSSH client including scp.exe
Sorry, religiously object to Windows 10 :D;)
Like to control what information I leak and to whom ...... not to mention the 'Chad Valley' UI !!! :D
 
Heh, maybe putty has a better implementation as well? I’ve used their pscp.exe to transfer files to/from Asus routers.
 
I also regularly use scp to move files between my development VM and my routers, never had any issue.
 
I also regularly use scp to move files between my development VM and my routers, never had any issue.
I would normally agree, I have used it a lot with no issues BUT recently found this 'one example' where using 'Duplicate' (in WinSCP) copied a sub-directory over itself incorrectly !!!???

I have been able to replicate it (multiple times) AND I have been able to solve it by using 'cp' from the coreutils package.
[BTW: It is in the latest version (Ver5.13.2) and in a random older version I tried (Ver-5.9.5). so not a recent change or bug AFAIK.]


The issue has raised the fact that WinSCP uses 'cp -p -r -f -T xxxxx' to copy file/directories, the Busybox 'cp' does not have the '-T flag'.
The coreutils 'cp' does have the '-T flag' and then WinSCP works for the example where it did not !!!???

As I stated, I do not expect WinSCP to include some exception when it works everywhere else & ditto for 'Asuswrt-Merlin' where it does work if you use the Busybox 'cp' command appropriately.

Just a heads-up that there is an instance where the recursive copy in WinSCP does not work.


The fact I could replicate it was the reason I raised the issue, it was not some mistype or error by me AFAIK.
(Just tried it again, before typing this reply ...... still get the same issue !!!)
The steps are in the issue, if someone wants to try !!!


Basically copy a directory over another by selecting all the contents (including a subdirectory with contents) ...... note the lowest level of the subdirectory and repeat the same action.
The subdirectory is NOT overwritten but appears within the sub-directory 1 level lower.

In the example the contents of '.../lib/' containing a directory 'opkg...' was copied to '.../[Backup]-lib/...'
The 1st 'Duplicate' (copy) works correctly as nothing is being overwritten.
The 2nd 'Duplicate' (copy) writes the 'opkg' directory inside the existing 'opkg' directory instead of overwriting 'opkg' and its contents.
 
@Twiglets Well, it took me quite a while to understand the problem :rolleyes:, and even longer to setup a test scenario :p.

But yes, I can confirm your observations using the very latest WinSCP. I must admit I wasn't even aware of the Duplicate function. Not being able to browse to the destination directory feels a bit clunky though.

As you say, the problem is specifically when copying directories that already exist in the root of the destination location.

However there does appear to be a way around it :). If you tick the "Duplicate via local temporary copy" box the problem doesn't occur.

Untitled.png
 
@Twiglets Well, it took me quite a while to understand the problem :rolleyes:, and even longer to setup a test scenario :p.

But yes, I can confirm your observations using the very latest WinSCP. I must admit I wasn't even aware of the Duplicate function. Not being able to browse to the destination directory feels a bit clunky though.

As you say, the problem is specifically when copying directories that already exist in the root of the destination location.

However there does appear to be a way around it :). If you tick the "Duplicate via local temporary copy" box the problem doesn't occur.

View attachment 13511
Many Thanks :D, nice to know it was not just me ..... did have some small niggling doubt BUT could not see where I was going wrong.
It is very specific to the 'Duplicate' action and only if you overwrite a Directory.

Never thought of the 'via Temporary copy' work around :(:rolleyes:
(I have never used the 'Temporary copy option' before !!!??? ...... until now. :D)

I will update the issue at WinSCP.

Solved by 2 methods ..... whichever suits best. Yay!!!! :D
 
Busybox does not support the -T flag (at least the option isn't available in 1.25, I didn't check later releases). Since so many embedded devices run busybox, might be worth raising the issue to WinSCP developers.
 
Busybox does not support the -T flag (at least the option isn't available in 1.25, I didn't check later releases). Since so many embedded devices run busybox, might be worth raising the issue to WinSCP developers.
I have updated the issue with both solutions and advised that the '-T Flag' is missing on Busybox implementations and may require some documentation to cover the possible issues.

Thanks all for your Help, confirming the error and solving the problem in an easier way.
 
  • Like
Reactions: kfp
Busybox does not support the -T flag (at least the option isn't available in 1.25, I didn't check later releases). Since so many embedded devices run busybox, might be worth raising the issue to WinSCP developers.

cp -T (no target directory) is part of GNU's coreutils package, but the -T flag itself is outside of posix....

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html#tag_20_24

GNU's cp...

http://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html#cp-invocation

Not a bug in busybox - it's a flawed assumption by the authors of WinSCP - not every host will be running a cp that supports that command (and not every host that supports scp is gnu-linux - BSD native cp doesn't support that flag either)
 
As you say, the problem is specifically when copying directories that already exist in the root of the destination location.

However there does appear to be a way around it :). If you tick the "Duplicate via local temporary copy" box the problem doesn't occur.

Sounds like a decent work-around...
 
cp -T (no target directory) is part of GNU's coreutils package, but the -T flag itself is outside of posix....

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html#tag_20_24

GNU's cp...

http://www.gnu.org/software/coreutils/manual/html_node/cp-invocation.html#cp-invocation

Not a bug in busybox - it's a flawed assumption by the authors of WinSCP - not every host will be running a cp that supports that command (and not every host that supports scp is gnu-linux - BSD native cp doesn't support that flag either)
Thanks, have passed on that it is also missing in BSD native 'cp' as well.
To be honest I cannot remember ever using a '-T flag' and did not understand what it was meant to do, even after reading the Manpage !!!
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top