I am writing a Java code for Linux RHEL 5 machine. The requirement is that while sitting at machine A, I should be able to edit some files in a remote machine B. Both machine A & B are RHEL. Now the following possibilities are there. Can anyone please suggest which is better or if any other way is there:
Write a shell script to do this. Execute the shell script from A such that changes happen in B
Write a java code on A, that is able to login to B and edit files in B.
Write a java file editing utility (pattern-matching thing). Push this util on B through another java code. Execute the file edit util in B. Somehow the trigger for executing the util in B should also be given by
Dorothy Taylor wrote:Ok, I want to do it programmatically not manually. So opening a file and editing it is not an option
OK - my misunderstanding . You could use one of the Java (or whatever language you are writing in) SFTP libraries to read the remote file from machine B into your program running on A, edit it and then write it back again. This would require you to have an SFTP server running on machine B. If you have installed openssh on machine B then you automatically get an SFTP server.
My second option is still applicable - using NFS just mount the B directory on A and your program can access it directly.