The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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-15-2008 01:42 PM
List only the files chandran.m SUN Solaris 5 12-06-2007 03:03 PM
How to list top 10 files satish_1983 UNIX for Dummies Questions & Answers 4 10-26-2007 08:05 AM
list files alisevA3 UNIX for Dummies Questions & Answers 2 03-21-2007 02:40 AM
list files avadhani UNIX for Dummies Questions & Answers 7 06-21-2005 02:25 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-10-2007
bkan77 bkan77 is offline
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
  #2 (permalink)  
Old 08-11-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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)
  #3 (permalink)  
Old 08-11-2007
porter porter is offline Forum Advisor  
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.
  #4 (permalink)  
Old 08-13-2007
bkan77 bkan77 is offline
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
  #5 (permalink)  
Old 08-13-2007
bkan77 bkan77 is offline
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
  #6 (permalink)  
Old 08-15-2007
bkan77 bkan77 is offline
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
  #7 (permalink)  
Old 08-15-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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?
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0