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

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Post Reply
User avatar
Dave
Jedi Knight
Posts: 901
Joined: 2004-02-06 11:55pm
Location: Kansas City, MO

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

Post 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.
User avatar
Resinence
Jedi Knight
Posts: 847
Joined: 2006-05-06 08:00am
Location: Australia

Post 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?
“Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation.” - Oscar Wilde.
User avatar
Durandal
Bile-Driven Hate Machine
Posts: 17927
Joined: 2002-07-03 06:26pm
Location: Silicon Valley, CA
Contact:

Post 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 $?.
Damien Sorresso

"Ever see what them computa bitchez do to numbas? It ain't natural. Numbas ain't supposed to be code, they supposed to quantify shit."
- The Onion
User avatar
Braedley
Jedi Council Member
Posts: 1716
Joined: 2005-03-22 03:28pm
Location: Ida Galaxy
Contact:

Post 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.
Image
My brother and sister-in-law: "Do you know where milk comes from?"
My niece: "Yeah, from the fridge!"
User avatar
Dave
Jedi Knight
Posts: 901
Joined: 2004-02-06 11:55pm
Location: Kansas City, MO

Post 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.
User avatar
Chris OFarrell
Durandal's Bitch
Posts: 5724
Joined: 2002-08-02 07:57pm
Contact:

Post 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).
Image
User avatar
Dave
Jedi Knight
Posts: 901
Joined: 2004-02-06 11:55pm
Location: Kansas City, MO

Post 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.
User avatar
Chris OFarrell
Durandal's Bitch
Posts: 5724
Joined: 2002-08-02 07:57pm
Contact:

Post by Chris OFarrell »

Sure its not creating a copy of the 'filename' file as '....' in the same level of the directory structure?
Image
User avatar
Resinence
Jedi Knight
Posts: 847
Joined: 2006-05-06 08:00am
Location: Australia

Post 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 ....
“Most people are other people. Their thoughts are someone else's opinions, their lives a mimicry, their passions a quotation.” - Oscar Wilde.
User avatar
Durandal
Bile-Driven Hate Machine
Posts: 17927
Joined: 2002-07-03 06:26pm
Location: Silicon Valley, CA
Contact:

Post 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.
Damien Sorresso

"Ever see what them computa bitchez do to numbas? It ain't natural. Numbas ain't supposed to be code, they supposed to quantify shit."
- The Onion
User avatar
EnsGabe
Youngling
Posts: 54
Joined: 2006-07-10 09:49pm

Post 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.
The Monarch: "Anyone wanna explain to me why my coccoon is charred?"
24: "Because you told us to blow it up"
The Monarch: "And why it is sideways?"
21: "We were following orders! You can't yell at us for following orders."
24: "Or kill us for following orders."
Post Reply