Script Test [OT]
cs at zip.com.au
Sat Sep 6 21:45:05 UTC 2008
On 06Sep2008 12:01, kwhiskerz <kwhiskerz at gmail.com> wrote:
| A suggestion I found on the net is to test for the value of md5sum
That's horrible. Unreliable, etc.
| Now, does this stay the same, even if a password is added or
With shadow passwords, yes. But if someone: changes their name, changes
their shell, changes their homedir, a new user is added, a user is
deleted. All these will break the test.
| Is it unique to a computer?
And it is not unique.
It is a very bad suggestion.
Just check hostname (and maybe domainname, depending how widely
your test needs to wordk).
| And also, how do I isolate the number and
| strip off the space and "/etc/passwd" from the result?
With cut or sed or awk or perl or ...
But since it is a "signature", who cares if the filename is there or
not? Just compare the full thing.
Seriously, don't do the md5sum thing.
Personally, I try to set up three environment variables: $HOSTNAME,
being the full hostname (foo.example.com), $HOST, being the shortname
(foo) and $SYSTEMID being what I call the "administrative zone" ("home"
at home, "cisra" at a former workplace of that name, etc). These are
all arbitrary and of course need special setup everywhere, but once they
are there it is possible to make sensible comparison statements. Then
the problem moves from an ad hoc test in a script to maintaining these
variables, which at least is a better defined problem.
So my scripts which care tend to say:
case "$HOST@$SYSTEMID" in
fleet at home)
# my laptop ...
and so forth.
Cameron Simpson <cs at zip.com.au> DoD#743
I am returning this otherwise good typing paper to you because someone has
printed gibberish all over it and put your name at the top.
- English Professor, Ohio University
More information about the users