Page 1 of 1

WTF does the *nix command "cp ...." go to?

Posted: 2008-03-31 12:02am
by Dave
So a friend of mine was just working in a Linux shell, and managed to execute the command

Code: Select all

cp ....
which came back without error.

He was in his home directory on a remote account, so he does not have permission to write to a higher directory.

What did he just do? I can't figure it out.

Posted: 2008-03-31 12:10am
by Resinence
*opens terminal*

-bash-3.2$ cp ....
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file ... target_directory
-bash-3.2$

Regardless, I'd say he did...nothing. Since it got no input or output files. Was it piped through something suppressed the error output?

Posted: 2008-03-31 02:41am
by Durandal
To check and see if it really came back without an error, run

Code: Select all

$ echo $?
It should come back with 0 if there was no error.

Note that echo'ing the $? will return the result of the last command performed. So to check the status, have your friend execute cp .... again and then check $?.

Posted: 2008-03-31 09:26am
by Braedley
Were there actually files there, or was it just "cp ...." that he typed into terminal, because for me, it won't run as it wants a destination file.

Posted: 2008-03-31 01:33pm
by Dave
No pipes or anything. It was just "cp .... " with normal user privileges. I assume that there were at least folders in the directory he was using, and I assume that he had read/write privilages both to the folder he was in (it was his home directory), and the folders inside of it.

He would not have write privilages to the folder above him.

It returned a prompt as though it had executed. I saw it myself:

Code: Select all

[dkn2n4@rc13cslinux ~]$ cp ....
[dkn2n4@rc13cslinux ~]$
When I run it from my home directory, using a remote server like he did, I get:

Code: Select all

[dkn2n4@rc13cslinux ~]$ cp ....
cp: missing destination file
Try 'cp --help'  for more information.
[dkn2n4@rc13cslinux ~]$
if we use cd instead (a possible mispelling) we get:

Code: Select all

[dkn2n4@rc13cslinux ~]$ cd ....
-bash: cd: ....: No such file or directory
[dkn2n4@rc13cslinux ~]$
I will ask him to reproduce the error and echo it.

Posted: 2008-03-31 07:21pm
by Chris OFarrell
Also check to see if he is being a smart ass and has some script or something called 'cp' in the dir he is showing you he is running the things. And check his path variables, he might be pointing to somewhere before whereever his cp implementation is being stored, which has some weird cp implementation that is happy (just use 'which' to check his against yours).

Posted: 2008-03-31 10:45pm
by Dave
Ok, I spoke with my roomate, and apparently he actually ran the command

Code: Select all

cp filename ....
That probably changes things significantly. I just tried it, and it does execute with error-level zero.

I tried it 5 folders deep, and I can't find the file I just copied.

Posted: 2008-03-31 10:57pm
by Chris OFarrell
Sure its not creating a copy of the 'filename' file as '....' in the same level of the directory structure?

Posted: 2008-03-31 11:02pm
by Resinence
A '.' at the start of the filename designates it to the system as an invisible file, turn on invisible files in whatever manager you use. Going up 2 directories would be ../.. not ....

Posted: 2008-03-31 11:36pm
by Durandal
Dave wrote:Ok, I spoke with my roomate, and apparently he actually ran the command

Code: Select all

cp filename ....
That probably changes things significantly. I just tried it, and it does execute with error-level zero.

I tried it 5 folders deep, and I can't find the file I just copied.
It would have created a file named "...." in the working directory, which was a copy of filename.

Posted: 2008-03-31 11:39pm
by EnsGabe
Durandal wrote: It would have created a file named "...." in the working directory, which was a copy of filename.
And since it has a leading '.', most file viewing utilities acknowledge that it's a hidden file and don't display it. 'ls -A' is the trick there.