Read from file and split varialble

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
  1. Read the file config_details.txt in loop and go through the records in the file from second line onwards.
  2. Login to the server based on the IP address, username, password provided in the config_details.txt file.
  3. Go to the path as mentioned in directory_path.
  4. Copy the file e.g. error.log to the local directory.
  5. 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

Looks like you want to write a shell script; for which shell? e.g. bash or ksh allow to read individual variables from a line in a file, and, on top, to define the field separator, in your above case a comma.
But, most importantly, you should redirect the stdin file descriptor using < , NOT the stdout fd like you do.