GNU bug report logs - #23213
cp command with -P option odd behavior over ssh

Previous Next

Package: coreutils;

Reported by: Kousik Mandal <kousikmandal <at> gmail.com>

Date: Mon, 4 Apr 2016 11:14:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Kousik Mandal <kousikmandal <at> gmail.com>
To: 23213 <at> debbugs.gnu.org
Subject: bug#23213: More observation on cp command option
Date: Mon, 4 Apr 2016 22:11:14 +0530
[Message part 1 (text/plain, inline)]
Hi Team,

Last time in my email one space was missing and that lead to confusion I
guess. I am very sorry for typo.

The cp command I tried to execute over ssh

----snip---
[user1 <at> test ~]$ *ssh user1 <at> test       sh -c  'cp -vPprf /tmp/123 /tmp/4576'*
user1 <at> test's password:
cp: missing file arguments
Try `cp --help' for more information.
----snip---
last time by mistake I missed space between ssh user1 <at> test and sh -c  'cp
-vPprf /tmp/123 /tmp/4576'

but it's always failing. I have tried the same command on multiple Linux
system and found same failure.


I dig into further following are the observations

---snip---
[user1 <at> test ~]$
*which cp/bin/cp*

[user1 <at> test ~]$
*cp --versioncp (GNU coreutils) 5.97*
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software.  You may redistribute copies of it under the terms of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
---snip---

Then I execute
[user1 <at> test ~]$ *ssh user1 <at> test sh -c  "'which cp; cp -vPprf /tmp/123
/tmp/4576'"*
user1 <at> test's password:
*/usr/local/bin/cp*
cp: Warning: the meaning of `-P' will change in the future to conform to
POSIX.
Use `--parents' for the old meaning, and `--no-dereference' for the new one.
/tmp -> /tmp/4576/tmp
`/tmp/123' -> `/tmp/4576/tmp/123'


[user1 <at> test ~]$* /usr/local/bin/cp --version*
cp (fileutils) 4.1
Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.

Copyright (C) 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


So from the above observation it's very clear the problem is while trying
to execute cp command over ssh then it's taking */usr/local/bin/cp *instead
of
*/bin/cp *which is causing the problem.


But in *PATH *env variable */bin* is preceding */usr/local/bin *
[user1 <at> test ~]$ *echo $PATH*
/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:*/bin*
:/usr/bin:/usr/dev_infra/platform/bin:/usr/dev_infra/generic/bin:
*/usr/local/bin*:/usr/X11R6/bin:/usr/local/ade/bin:/scratch/user1/bin

Even I checked in over ssh in PATH /bin appearing before /usr/local/bin
[user1 <at> test ~]$ *ssh user1 <at> test   sh -c  "'echo $PATH; which cp; cp -vPprf
/tmp/123 /tmp/4576'"*
user1 <at> test's password:
/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:*/bin*
:/usr/bin:/usr/dev_infra/platform/bin:/usr/dev_infra/generic/bin:
*/usr/local/bin*:/usr/X11R6/bin:/usr/local/ade/bin:/scratch/user1/bin
*/usr/local/bin/cp*
cp: Warning: the meaning of `-P' will change in the future to conform to
POSIX.
Use `--parents' for the old meaning, and `--no-dereference' for the new one.


Can you please give me any pointer why over ssh cp command is taking
*/usr/local/bin
*specific executable rather than* /bin* specific executable?

Is there any way to force the cp command to take /bin specific executable
over ssh?

Thanks in advance.

Best Regards,
Kousik
[Message part 2 (text/html, inline)]

This bug report was last modified 9 years and 46 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.