Hello Experts,
Can anybody assist me in writing a code to do the following:
I have a file present in the same directory from where this cod would run. The content of the file would be as below:
Config Filename: config_details.txt
Format:
Server_prefix,IP_of_server,username, password, directory_path, file_name
Example:
S1,127.0.0.1,xyz_user1,xyz_password1, /home/xyz1/logs/,error.log
S2,127.0.0.1,xyz_user2,xyz_password2, /home/xyz2/logs/,error.log
- Read the file config_details.txt in loop and go through the records in the file from second line onwards.
- Login to the server based on the IP address, username, password provided in the config_details.txt file.
- Go to the path as mentioned in directory_path.
- Copy the file e.g. error.log to the local directory.
- Move to the next server details in the config_Details.txt file and repeat step 1to 5.
There are other steps involved in this script which I have managed to do already. I can read from the file using below code. But I cannot read the variables e.g.server name or username etc from the file. It is either full line or nothing.
while read line; do echo $line; done > config_details.txt
Any help would be appreciated.
Thanks
Chetan