fireburn11
asked on
linux bash script that find files on remote servers
Hi All,
I have about 20 Centos OS servers and I need a script that read a text file that contains a list of server names, then go into each server and find out if a particular file exists, if it does, write the host name to fileexsit.txt and it the file doesn't exist, write to a file named filenotexist.txt.
Please help!!
Thanks!
I have about 20 Centos OS servers and I need a script that read a text file that contains a list of server names, then go into each server and find out if a particular file exists, if it does, write the host name to fileexsit.txt and it the file doesn't exist, write to a file named filenotexist.txt.
Please help!!
Thanks!
Have you set up key based authentication from the server running the script to the servers in question and does the user with key based authentication have access to the areas of the file system where you are looking for files? Are you able to specify where the file should exist (that is, do you know the exact file name and directory, or just the file name)? In the absence of key based authentication (I would not recommend password based for use in scripts), are the file locations accessible through NFS shares? My reasons for asking is so that I (or another expert) can provide you with the most suitable script.
ASKER
Hi Marty,
Yes, Key based authentication is enabled for my account and I do have access to the directory where files are located at. the file is located in:
./etc/clamav.conf
Thanks.
Yes, Key based authentication is enabled for my account and I do have access to the directory where files are located at. the file is located in:
./etc/clamav.conf
Thanks.
OK. Firstly, your file name starts with a "." character, which refers to the current directory. On the target server, if a simple bash command is run and used to locate the file, it will more than likely refer to the home directory of the user that is used to locate the file. Did you mean "/etc/clamav.conf"? Is that the actual file name, or is it a directory name (I am not that familiar with clamav, but in CentOS, the configurations are usually in /etc/clam.d" IIRC)? Secondly, are you looking for the existence of that file, or are you wanting to parse the contents of the file to locate a specific file mentioned as one of the parameters in the config file?
ASKER
yes I mean "/etc/clamav.conf".
I am just looking for the existence of that file.
Thanks.
I am just looking for the existence of that file.
Thanks.
OK. Will be back to you with my script. Someone else may pop in with a quick response too now that they have more detail :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the input Noci - useful addition.