The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
list the files but exclude the files in subdirectories shyjuezy UNIX for Dummies Questions & Answers 8 10 Hours Ago 10:42 AM
List only the files chandran.m SUN Solaris 5 12-06-2007 11:03 AM
How to list top 10 files satish_1983 UNIX for Dummies Questions & Answers 4 10-26-2007 05:05 AM
list files alisevA3 UNIX for Dummies Questions & Answers 2 03-20-2007 10:40 PM
list files avadhani UNIX for Dummies Questions & Answers 7 06-20-2005 11:25 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-10-2007
Registered User
 

Join Date: Jul 2007
Posts: 53
list of files

Hi all

I wrote a script as a part of it the scp command copies some selected files from the source server to the target server,but now i want to display(not to the user ,but for my refernce) the list of files on the target server and remove the files that are not common in the source and target,in other words after the scp command is executed the source and traget server must have the same files.Any kind of advice is appreciated.

thnks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-10-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
You can use rsync for this. Rsync works over ssh as well. If you have to write your own script, you can do something like this:

1. ssh to remote and get list of files (use ssh and ls on remote path)
2. compare remote list with local list and create list of files to remove (files that are not present locally) (use comm command)
3. ssh to remote and remove files that are in the list (use ssh and rm on remote path)
4. scp files from local to remote (scp as in current script)
Reply With Quote
  #3 (permalink)  
Old 08-10-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
You could use "ssh ... find ..." to get the list of the files on both machines and use "diff" to give you the list of what the differences are.
Reply With Quote
  #4 (permalink)  
Old 08-13-2007
Registered User
 

Join Date: Jul 2007
Posts: 53
list of files

Quote:
Originally Posted by blowtorch View Post
You can use rsync for this. Rsync works over ssh as well. If you have to write your own script, you can do something like this:

1. ssh to remote and get list of files (use ssh and ls on remote path)
2. compare remote list with local list and create list of files to remove (files that are not present locally) (use comm command)
3. ssh to remote and remove files that are in the list (use ssh and rm on remote path)
4. scp files from local to remote (scp as in current script)
thnks for the reply
but what i wanted was ,that i dont watn to login onto the remote server manually,i want my script to do that and it must automatically detect find out the list of files and delete the old one's on the remote server to make the list look identical on both the source and the target

thnk you,its urgent so pls any kind of idea is appreciated
Reply With Quote
  #5 (permalink)  
Old 08-13-2007
Registered User
 

Join Date: Jul 2007
Posts: 53
list of files

Quote:
Originally Posted by porter View Post
You could use "ssh ... find ..." to get the list of the files on both machines and use "diff" to give you the list of what the differences are.
thnks for the reply
but what i wanted was ,that i dont watn to login onto the remote server manually,i want my script to do that and it must automatically detect find out the list of files and delete the old one's on the remote server to make the list look identical on both the source and the target

thnk you,its urgent so pls any kind of idea is appreciated
Reply With Quote
  #6 (permalink)  
Old 08-15-2007
Registered User
 

Join Date: Jul 2007
Posts: 53
Quote:
Originally Posted by porter View Post
You could use "ssh ... find ..." to get the list of the files on both machines and use "diff" to give you the list of what the differences are.
can you pls elaborate on that,as to how to find the files,pls can you give an example
Reply With Quote
  #7 (permalink)  
Old 08-15-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
Quote:
Originally Posted by bkan77 View Post
thnks for the reply
but what i wanted was ,that i dont watn to login onto the remote server manually,i want my script to do that and it must automatically detect find out the list of files and delete the old one's on the remote server to make the list look identical on both the source and the target

thnk you,its urgent so pls any kind of idea is appreciated
I never said that the steps that I mentioned were to be executed manually. Have you understood what I was trying to say?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0