Compare folder/files from remote server
Friends ,
Suppose I have two same folders in machine A (Linux) and in machine B (Linux) . Now I am compare these two files using "diff" command . I mean running diff command in following way : diff folder1 (machine A) folder2 (machine B) Can I do it ? Plz help .. ... |
You said file and folder. Which do you mean?
Diff compares the contents of two files. It does not (directly) compare directories. Diff compares files only - not URLs. When you say remote, what do you mean? If the remote files are mounted on the local system using NFS or SMB or something else which allows you to see them in the local filesystem this is fine, but if you access the files using HTTP or FTP, this is a little more complicated. |
diff command in remotely
Thx matthewg42 .
Acyually I have a file called "file1" in Linux A . In Linux B i have same file caled 'file2' Now i need to run diff command in a shell script . But I cannot go to the file2 in LinixB easily . So that I need ur help how can I comapre this two files where files are in different machines ...... Waiting ur kind reply .. ... |
Some more questions:
|
You can compare files remotely using ssh like this
Code:
ssh <remote-host> "cat /path/to/remotefile" | diff - /path/to/localfile Code:
diff - /path/to/localfile Maybe you have to elaborate to suite to your needs. For example, you may want to generate private/public ssh keys to avoid prompting for password. Also if you want to compare files with blank space in their name you have to escape it, e.g. Code:
ssh <remote-host> "cat remote\ file" | diff - local\ file |
diff in remoter server
sorry colucix ,
ssh is not directly connected to the remote server without password , is it ? It shows follwoign error : [root@server ~]# ssh 192.168.101.129 "cat /tmp/file2" | diff - /root/file1 diff: cannot compare `-' to a directory connect to address 192.168.101.129: Connection refused Trying krb4 ssh... connect to address 192.168.101.129: Connection refused trying normal ssh (/usr/bin/ssh) sshd: 0826-826 The host name for your address is not known. |
Quote:
Quote:
|
Here's how to configure ssh to work using public key authentication (which you can use to do remote commands without being prompted for a password each time):
http://sial.org/howto/openssh/publickey-auth/ |
Quote:
|
I only can imagine the following:
ssh your@connection find ./folder -type f -exec cat \;>> ./freespace; find ./folder -type f -exec cat \; >> ./evenmorespace; diff ./freespace ./evenmorespace |
Or use sshfs to mount the remote directory through ssh (it requires FUSE) and then just diff recursively. Here is a quick and dirty example (suppose you have to compare /path/to/local/dir and /path/to/remote/dir)
Code:
$ mkdir local-mount-point |
Quote:
|
Quote:
|
All times are GMT -5. The time now is 02:53 PM. |