[K12OSN] while read do questionts

Michael C Wescott wescott at sc.rr.com
Sat Feb 5 18:21:29 UTC 2005

>>> ok coders: can you get me round this stupid brain-flattulence. 
>>> run 2000 users thru this piece of script and uid increments on
>>> each pass.so at end of script uid otter be 2027 or summat..

>> In the script it is 2027 right up the script dies. When the process
>> running the script dies that value dies with it and you're left with
>> whatever it was set to before the script started.
>> Variables, like uid or PATH, are not kept in some global area 
>> common to all of your processes. Instead they are local to each
>> process, with the initial values inherited from the parent process.
>> When a process, like a shell script, changes the value it does so
>> for its own copy. To do what you want, you'll have to explicitly
>> save the value somehow, say in a file.

> yeah: i kinda thought as much..thanks for the comeback..this is
> one piece of a much larger smblda script..chuck

Even within a script you can see variable problems like this. Some
constructs in a script can be made into subprocesses of the parent
script, often when you don't expect it.

More information about the K12OSN mailing list