LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-22-2011, 11:07 AM   #1
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
cp overwrite over ssh


Is there a way to force copy in ssh?

When i use the mv command it give me the same error

Code:
 
casper@casperbox:~$ ssh casper@192.168.81.95 "cp -fr /home/clearing.txt /home/casper/clearing/"
cp: `/home/clearing.txt' and `/home/casper/clearing/clearing.txt' are the same file
right now i am moving the file away and then copying it...

ssh casper@172.29.81.95 "mv /home/casper/clearing/clearing.txt /tmp/"

Last edited by casperdaghost; 02-24-2012 at 02:32 PM.
 
Old 12-22-2011, 11:23 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,043
Blog Entries: 14

Rep: Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212
"the same file"

If this is a hard link then it is in fact "the same file" and there is no need to copy from one to the other.

Run "ls -l /home/casper/clearing/" if you see a number higher than 1 in the second column (between mode and owner) then the file is a hard link. If you run "ls -i" on both files they should show the same inode number if they are the same.

Are you doing this copy after updating /home/clearing.txt? If the other one is a hard link to this one then there is no reason to do the copy at all. Any changes to the first one are also changes to the second one as they ARE "the same file".
 
Old 12-22-2011, 11:29 AM   #3
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Original Poster
Rep: Reputation: 16
it is a file of the same name, however it is updated daily.
i am working on maybe getting some rsync going so I dont have to transfer the whole file just the changes.

until then I am using keyed ssh to mv the file, then copy the file.

if the file is there, it will not copy.

i wan to force an overwrite over ssh
 
Old 12-24-2011, 06:28 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,043
Blog Entries: 14

Rep: Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212Reputation: 1212
You're not transferring a file with the above - you're ssh'ing into the other machine then doing a local copy on it.

You'd need to use scp rather than cp to "copy" from one machine to another. Of course you can also do rsync for such copies. If you type "man scp" and "man rsync" you can see options including those for overwriting if the file is already there. However, one of the main benefits of rsync is to only copy those things that don't already exist - thereby saving network bandwidth.
 
Old 12-27-2011, 07:39 AM   #5
vikas027
Senior Member
 
Registered: May 2007
Location: Sydney
Distribution: RHEL, CentOS, Ubuntu, Debian, OS X
Posts: 1,300

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by casperdaghost View Post
Is there a way to force copy in ssh?

When i use the mv command it give me the same error

Code:
 
casper@casperbox:~$ ssh casper@172.29.81.95 "cp -fr /home/clearing.txt /home/casper/clearing/"
cp: `/home/clearing.txt' and `/home/casper/clearing/clearing.txt' are the same file
walt@walt-nasdaq:~$
right now i am moving the file away and then copying it...

ssh waljoh@172.29.81.95 "mv /home/casper/clearing/clearing.txt /tmp/"
Try using,
Code:
  ssh waljoh@172.29.81.95 "mv /home/casper/clearing/clearing.txt /tmp/ --reply=yes"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
why does X overwrite my rc.keyb? stabu Slackware 5 10-22-2009 02:15 AM
Overwrite XP completely!!! mneekhrey Linux - Newbie 5 11-04-2007 06:57 AM
sed overwrite schneidz Programming 8 09-21-2005 03:56 PM
Copy and Overwrite jrdioko Linux - Newbie 2 06-29-2004 12:46 PM
Can't overwrite MBR Elmo Linux - General 2 03-13-2003 02:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration