SCP wihout a source path


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users SCP wihout a source path
# 1  
Old 03-02-2012
SCP wihout a source path

Hi,

I hope someone can explain if this is the right behaviour. I regularly use scp to copy files between hosts like this:

Code:
scp -prv user@remotehost:/path/to/copy .

However, today, I made a mistake and typed this instead:
Code:
scp -prv user@remotehost: /path/to/copy .

This started copying user@remotehosts $HOME to . on the local host I was on.

So I have now tried
Code:
scp -prv user@remotehost: .

which also copies $HOME to . on the local host. I did not know you could do this. I am under the impression that I must always include a path or at lease /.

What puzzles me further, is how in
Code:
scp -prv user@remotehost: /path/to/copy .

it starts writing everything to . instead of /path/to/copy.

Is this the expected behavior? Is it a bug which can be fixed? Could someone please shed some light on this?

Last edited by pludi; 03-12-2012 at 08:58 AM..
# 2  
Old 03-02-2012
I'd consider it a bug, as you've not given any source files -- it should not be finding anything to send. When I try it with my implementation(linux, openssh) I get this error:

Code:
scp: .: not a regular file
cp: omitting directory `/path/to/dirname'

If I choose a folder that does not exist on localhost:

Code:
scp: .: not a regular file
cp: cannot stat `/path/to/dir2': No such file or directory

# 3  
Old 03-02-2012
Thanks for responding Corona. Can you share what version you run?

My Server runs:

"Linux myhostname 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux"

Red Hat Enterprise Linux Server release 5.7 (Tikanga)

openssh-clients-4.3p2-72.el5_6.3

Could anyone confirm this for me?
# 4  
Old 03-02-2012
The kernel and bit width isn't relevant.

My version of openssh is openssh-5.6_p1-r2

It may also have to do with what $HOME ends up being when you scp in there. Might it somehow end up as a file?
# 5  
Old 03-02-2012
No it was actually $HOME of the user. I almost wiped out my data. I did a test afterwards on a test system. It copied all the $HOME data
# 6  
Old 03-02-2012
Well, is the remote system any different from yours? That's just as important. Expansion on the remote side has been sometimes known to occur strangely on proprietary SSH implementations.
# 7  
Old 03-12-2012
Not A Bug

The path after : is optional, with the default being the remote user's
home directory. Consider "scp blah.txt user@host:"

For the case of "scp -prv user@remotehost: /path/to/copy .", it's doing
exactly what you tell it: copying user@remotehost's home directory as
well as /path/to/copy to your local home directory.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Command to see the logical volume path, device mapper path and its corresponding dm device path

Currently I am using this laborious command lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}' Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies

2. Web Development

Path to javascript source code at local browsing

Where should I put my javascript source code in order to run it "locally" by file not by http?---not sure this "locally" is the appropriate word here. My test is when my javascript code (test.js) is put in the site default folder as the test.html in /var/www/html both worked as expected with... (2 Replies)
Discussion started by: yifangt
2 Replies

3. Shell Programming and Scripting

Generate class path dynamically based on source path

Hi experts, I have multiple file names ending with .jsp located in $SOME_DIR, $SOME_DIR/f1/,$SOME_DIR/f2/test,$SOME_DIR/f3/fa and there are equivalent class files in $SOME_DIR/WEB-INF/classes/_pages,$SOME_DIR/WEB-INF/classes/_pages/_f1,... (0 Replies)
Discussion started by: oraclermanpt
0 Replies

4. Shell Programming and Scripting

I am trying to merge all csv files from source path into 1 file

I am trying to merge all csv files from source path into one single csv file in target. but getting error message: hadoop fs -cat /user/hive/warehouse/stage.db/PK_CLOUD_CHARGE/TCH-charge_*.csv > /user/hive/warehouse/stage.db/PK_CLOUD_CHARGE/final/TCH_pb_charge.csv getting error message:... (0 Replies)
Discussion started by: cplusplus1
0 Replies

5. Shell Programming and Scripting

Moving files from parent path to multiple child path using bash in efficient way

Hi All, Can you please provide some pointers to move files from Base path to multiple paths in efficient way.Folder Structure is already created. /Path/AdminUser/User1/1111/Reports/aaa.txt to /Path/User1/1111/Reports/aaa.txt /Path/AdminUser/User1/2222/Reports/bbb.txt to... (6 Replies)
Discussion started by: karthikgv417
6 Replies

6. UNIX for Dummies Questions & Answers

Source path

what is the command for moving a file with it's original source path ? (8 Replies)
Discussion started by: Oggie25
8 Replies

7. Linux

rpmbuild, how to specify a different source and destination path for files

I'd like to specify a different build and deployment path for files, by default the same path is used for both build and install, I wasn't able to find a way to make these different. With Solaris pkgadd, one can specify different paths in prototype, so I would assume something like that is possible... (0 Replies)
Discussion started by: tiburblium
0 Replies

8. UNIX for Advanced & Expert Users

Automated SCP script passing password to preserve source file timestamp

Hi My requirement is i want to copy files from remote server to the local server and also i need to preserve the timestamp of the remote file. By using scp -p , it is working fine in the interactive call but it is not preserving he file timestamp when i use it in the non interactive scp call... (1 Reply)
Discussion started by: skumar75
1 Replies

9. Shell Programming and Scripting

Reading an Input file and searching for occurrences WIHOUT SED or AWK

Hi people. I am new to shell scripting, so I need a little help. I want to create a script named that takes an argument as a file, Read the input file and look for occurrences of the current username (say abc.xyz) who is executing the script. On finding an occurrence of the username take that line... (2 Replies)
Discussion started by: kartikkumar84@g
2 Replies
Login or Register to Ask a Question