January 17th, 2013, 01:14 PM
Search Text File for String on Remote Computer
I'm trying to figure out how I can search for any occurance of a specific string in a text file on a remote computer. My OS is redhat 5. The following is a way, but not so sure it's the best way:
my $rc = `ssh -q machineName "cat /tmp/file.txt" | grep TextToSearch`;
print "found your string";
print "no such string";
January 18th, 2013, 02:21 AM
If it works, fine for you. After all, it is quite simple.
But it is usually better and more powerfil to use specialized CPAN modules rather than system commands. Take a look at the module.
January 18th, 2013, 09:17 AM