Ric Posted March 7, 2005 Share Posted March 7, 2005 Can any one tell me how to read variables from a text file so they can be used with in a bash script ie text file has serverone_host=amber serverone_ip=10.0.0.1 servertwo_host=green servertwo_ip=10.0.0.2 and so on bash file picks out the different variables so rather then having to edit a load of scrips i would only have to edit the text file each time i deploy a system gee i am asking the question and that doesn't make sense to me hope it make sense to some one out there Regards Ric Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted March 7, 2005 Share Posted March 7, 2005 . data_file (If it's in the same directory as your script) . /full/path/to/data_file (If it's n a different directory) Note that there is a space between . and the filename. Link to comment Share on other sites More sharing options...
Cannonfodder Posted March 8, 2005 Share Posted March 8, 2005 Are you asking to execute the file? Or read it in the manner of an .ini file? Read variable, get value, do something with it? Link to comment Share on other sites More sharing options...
Ric Posted March 8, 2005 Author Share Posted March 8, 2005 Are you asking to execute the file? Or read it in the manner of an .ini file? Read variable, get value, do something with it? <{POST_SNAPBACK}> Read it as a .ini file Thanks Link to comment Share on other sites More sharing options...
Steve Scrimpshire Posted March 8, 2005 Share Posted March 8, 2005 textfile: serverone_host=amber serverone_ip=10.0.0.1 servertwo_host=green servertwo_ip=10.0.0.2 text.sh: #!/bin/bash . textfile echo "$serverone_host" echo "$serverone_ip" echo "$servertwo_host" echo "$servertwo_ip" < omar ~ > ./text.sh amber 10.0.0.1 green 10.0.0.2 Link to comment Share on other sites More sharing options...
Ric Posted March 8, 2005 Author Share Posted March 8, 2005 Thats excactly what i needed, ive been trying to grep and awk my way thro it, this is so much easier. Thanks A Lot Ric Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now