Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable qustion

Status
Not open for further replies.

nimrodman

MIS
Nov 22, 2005
43
US
I have a script made and I am trying ot move the variable to separate file and parse it to the script, but it does not work as expected, is there any suggestion on how to get this done?
 
Sample code, do you mean you want to store variables into a file and then reparse/read it back? Generally, Unix scripts do not this because of issues with locking and synchronization with simultaneous runs.
Give us an example, please.

eugene
 
What you stated is precisely what I wanted to do, I am not really sure of how to do it, I have tried the while read line routine parsing the input of the variable from the end of file, but it was spewing out the worng feed back from a very good working script.

I have seeing it done a couple of places, but I just do nto know how.
 
nimrodman,

from your two posts in this thread I still don't understand what you are trying to do. Could you explain a bit more?

I guess that you might want what in your shell man pages is described as the builtins with names . or source. Details will depend on what shell you actually are using; you didn't tell us.

This is for a rather static list of variables. If you want to change your variables dynamically at runtime, then there will be a lot of problems. And elgrandeperro seems to have assumed the latter. (Sorry if I misunderstood!)
 
Something like

awk '{print $1}' file1 > file2

data() {
set -A array $(<file2)
A=${array[0]}
B=${array[1]}
C=...........
}

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top