- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: perl and ssh
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 06:05 AM
тАО07-25-2005 06:05 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 06:38 AM
тАО07-25-2005 06:38 AM
Re: perl and ssh
2. Other way to do it.
NFS mount from other host and running diff/uniq/comm on files.
3. Use of cksum on all files and compare those.
4. Line by Line comparision.
The old and crude way of doing it should be as follows.
ls -1 > file_list_local
remsh $remote -n 'ls -1' > file_list_remote
diff file_list_local file_list_remote
if [[ $? -eq 0 ]]; then
echo "files same on local and on remote host"
fi
for i in $(cat file_list_local)
do
line_count_local=`wc -l ${i}`
line_count_remote="`remsh $remote -n 'wc -l ${i}'"
if [[ ${line_count_local} -eq ${line_count_remote} ]];then
echo "sames lines in file ${i} on local and on remote"
else "Files remote ${i} not matching"
fi
done
SCRIPT not tested.
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 06:54 AM
тАО07-25-2005 06:54 AM
Re: perl and ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 07:05 AM
тАО07-25-2005 07:05 AM
Re: perl and ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 07:09 AM
тАО07-25-2005 07:09 AM
Re: perl and ssh
Anil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-25-2005 07:32 AM
тАО07-25-2005 07:32 AM
Re: perl and ssh
David,
I have no perl solution. :-(
*However* I do know that rsync does a very good job of comparing files, even if you don't actually want to copy them.
If you have the ability to install rsync on all of your servers, this is a tool that can be used for many purposes (not just this purpose), and it can run using ssh as the connection protocol. Rsync is available on the Software and Porting Archive.
For your purpose, you would use rsync with the -n option (or --dry-run).
Here is a ver quick and crude example of how you can use rsync to tell you if files are different. This example uses local directories, however you can also use the form hostname:/path/directory to compare remote directories. And you can use the -e option (--rsh=) to specify ssh.
[storm@thunder storm]$ ls -al 9c1
total 44
drwxrwxrwx 2 storm users 43 Jul 25 15:16 .
drwx--x--x 39 storm users 8192 Jul 25 15:14 ..
-rw------- 1 storm users 23142 Mar 30 1999 exhaust
-rw-r--r-- 1 storm users 738 Sep 14 1999 parts
-rw------- 1 storm users 2410 Apr 26 1999 wing
[storm@thunder storm]$ ls -al 9c1a
total 12
drwxrwxrwx 2 storm users 6 Jul 25 15:16 .
drwx--x--x 39 storm users 8192 Jul 25 15:14 ..
[storm@thunder storm]$ rsync -av 9c1/ 9c1a/
building file list ... done
./
exhaust
parts
wing
wrote 26532 bytes read 68 bytes 53200.00 bytes/sec
total size is 26290 speedup is 0.99
[storm@thunder storm]$ ls -al 9c1a
total 44
drwxrwxrwx 2 storm users 43 Jul 25 15:16 .
drwx--x--x 39 storm users 8192 Jul 25 15:14 ..
-rw------- 1 storm users 23142 Mar 30 1999 exhaust
-rw-r--r-- 1 storm users 738 Sep 14 1999 parts
-rw------- 1 storm users 2410 Apr 26 1999 wing
[storm@thunder storm]$ rsync -av 9c1/ 9c1a
building file list ... done
wrote 122 bytes read 20 bytes 284.00 bytes/sec
total size is 26290 speedup is 185.14
[storm@thunder storm]$
[storm@thunder storm]$ echo "different data now" > 9c1a/parts
[storm@thunder storm]$ rsync -nav 9c1/ 9c1a/
building file list ... done
parts
wrote 126 bytes read 24 bytes 300.00 bytes/sec
total size is 26290 speedup is 175.27
[storm@thunder storm]$
You will see in this example that I have two directories: 9c1 and 9c1a. I start off with 9c1a empty. Then I rsync it to 9c1 to make them the same. Then I change a file and run rsync -n again to show that it picked up and reported the changed file without actually copying anything.
Rsync is the most efficient and reliable freeware system I've seen around, and it uses checksums and sizes to determine if a file is different. It is also efficient in sending the differences across the network if you use it actually update files.
Hope this helps.
-- Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-26-2005 05:56 AM
тАО07-26-2005 05:56 AM
Re: perl and ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 12:14 AM
тАО07-27-2005 12:14 AM
Re: perl and ssh
I don't know any way to keep ssh connection open using perl, so you can:
- execute an script on remote host and then get the results
- get file you need to compare using rcp command
Regards,
Carles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-27-2005 01:56 AM
тАО07-27-2005 01:56 AM
SolutionBe sure you do checking that the file handle hasn't died on you though, given the extended period.