Re: Script Test [OT]

2008-09-09 Thread Cameron Simpson
On 08Sep2008 21:04, Kevin J. Cummings [EMAIL PROTECTED] wrote:
 Alan Evans wrote:
 On Mon, Sep 8, 2008 at 6:40 AM, Steven Tardy [EMAIL PROTECTED] wrote:
 kwhiskerz wrote:
 man hostid

 On my Fedora 9...
 $ hostid
 

 Now I haven't bothered to check any other machines, but my initial
 impression is that this is not going to work...

 I just checked the hostids on my 2 primary machines on the same local  
 network.  They just seem to be encodings of the machine's IP addresses.  
 And since both are PC class machines, the addresses look to be syllable 
 swapped (but not byte swapped).

 192.168.6.94 and 192.168.6.106
 a8c05e06 and a8c06a06

 So, I have to ask, does the machine you tried it on have an IP address?

So, let us turn to the docs: man hostid says:

  hostid - print the numeric identifier for the current host
  [...]
  The full documentation for hostid is maintained as  a  Texinfo  manual
  [...]

Gah. I hate this info-so-no-f'n-man-page rubbish!
But let's go: info hostid:
  
  21.4 `hostid': Print numeric host identifier.
  =
  `hostid' prints the numeric identifier of the current host in
  hexadecimal.  This command accepts no arguments.  The only options are
  `--help' and `--version'.  *Note Common options::.
 For example, here's what it prints on one system I use:
   $ hostid
   1bac013d
   On that system, the 32-bit quantity happens to be closely related to the
   system's Internet address, but that isn't always the case.

Gah! Again!

I don't think I'd rely on hostid for anything:-(

Cheers,
-- 
Cameron Simpson [EMAIL PROTECTED] DoD#743
http://www.cskk.ezoshosting.com/cs/

A good newspaper is never good enough, but a lousy newspaper is a joy
forever.- Garrison Keillor

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-09 Thread [EMAIL PROTECTED]

Cameron Simpson wrote:

On 08Sep2008 21:04, Kevin J. Cummings [EMAIL PROTECTED] wrote:

Alan Evans wrote:

On Mon, Sep 8, 2008 at 6:40 AM, Steven Tardy [EMAIL PROTECTED] wrote:

kwhiskerz wrote:
man hostid

On my Fedora 9...
$ hostid


Now I haven't bothered to check any other machines, but my initial
impression is that this is not going to work...
I just checked the hostids on my 2 primary machines on the same local  
network.  They just seem to be encodings of the machine's IP addresses.  
And since both are PC class machines, the addresses look to be syllable 
swapped (but not byte swapped).


192.168.6.94 and 192.168.6.106
a8c05e06 and a8c06a06

So, I have to ask, does the machine you tried it on have an IP address?


So, let us turn to the docs: man hostid says:

  hostid - print the numeric identifier for the current host
  [...]
  The full documentation for hostid is maintained as  a  Texinfo  manual
  [...]

Gah. I hate this info-so-no-f'n-man-page rubbish!
But let's go: info hostid:
  
  21.4 `hostid': Print numeric host identifier.

  =
  `hostid' prints the numeric identifier of the current host in
  hexadecimal.  This command accepts no arguments.  The only options are
  `--help' and `--version'.  *Note Common options::.
 For example, here's what it prints on one system I use:
   $ hostid
   1bac013d
   On that system, the 32-bit quantity happens to be closely related to the
   system's Internet address, but that isn't always the case.

Gah! Again!

I don't think I'd rely on hostid for anything:-(

Cheers,


Hi,

seeing the same (using dhcp for getting an ip address):

[EMAIL PROTECTED] [backes]: hostid


[EMAIL PROTECTED] [backes]: ifconfig
eth0  Link encap:Ethernet  HWaddr 00:0C:76:C0:40:36
  inet addr:192.168.179.182  Bcast:192.168.179.255 
Mask:255.255.255.0

  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
  RX packets:284 errors:0 dropped:0 overruns:0 frame:0
  TX packets:256 errors:0 dropped:0 overruns:0 carrier:0
  collisions:0 txqueuelen:1000
  RX bytes:86392 (84.3 KiB)  TX bytes:25620 (25.0 KiB)
  Interrupt:22 Base address:0x2000

Not seeing this effect on systems without dhcp usage.

Regards

--
Joachim Backes [EMAIL PROTECTED]



smime.p7s
Description: S/MIME Cryptographic Signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: Script Test [OT]

2008-09-09 Thread Ed Greshko
[EMAIL PROTECTED] wrote:
 Cameron Simpson wrote:
 On 08Sep2008 21:04, Kevin J. Cummings [EMAIL PROTECTED]
 wrote:
 Alan Evans wrote:
 On Mon, Sep 8, 2008 at 6:40 AM, Steven Tardy [EMAIL PROTECTED]
 wrote:
 kwhiskerz wrote:
 man hostid
 On my Fedora 9...
 $ hostid
 

 Now I haven't bothered to check any other machines, but my initial
 impression is that this is not going to work...
 I just checked the hostids on my 2 primary machines on the same
 local  network.  They just seem to be encodings of the machine's IP
 addresses.  And since both are PC class machines, the addresses look
 to be syllable swapped (but not byte swapped).

 192.168.6.94 and 192.168.6.106
 a8c05e06 and a8c06a06

 So, I have to ask, does the machine you tried it on have an IP address?

 So, let us turn to the docs: man hostid says:

   hostid - print the numeric identifier for the current host
   [...]
   The full documentation for hostid is maintained as  a  Texinfo  manual
   [...]

 Gah. I hate this info-so-no-f'n-man-page rubbish!
 But let's go: info hostid:
 21.4 `hostid': Print numeric host identifier.
   =
   `hostid' prints the numeric identifier of the current host in
   hexadecimal.  This command accepts no arguments.  The only options are
   `--help' and `--version'.  *Note Common options::.
  For example, here's what it prints on one system I use:
$ hostid
1bac013d
On that system, the 32-bit quantity happens to be closely related
 to the
system's Internet address, but that isn't always the case.

 Gah! Again!

 I don't think I'd rely on hostid for anything:-(

 Cheers,

 Hi,

 seeing the same (using dhcp for getting an ip address):

 [EMAIL PROTECTED] [backes]: hostid
 

 [EMAIL PROTECTED] [backes]: ifconfig
 eth0  Link encap:Ethernet  HWaddr 00:0C:76:C0:40:36
   inet addr:192.168.179.182  Bcast:192.168.179.255
 Mask:255.255.255.0
   UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
   RX packets:284 errors:0 dropped:0 overruns:0 frame:0
   TX packets:256 errors:0 dropped:0 overruns:0 carrier:0
   collisions:0 txqueuelen:1000
   RX bytes:86392 (84.3 KiB)  TX bytes:25620 (25.0 KiB)
   Interrupt:22 Base address:0x2000

 Not seeing this effect on systems without dhcp usage.

 Regards

FYI, the hostid does not use information from ifconfig.  It looks for a
match between hostname -s and information in /etc/hosts.  It then uses
the IP address contained there.  No match then hostid returns .


-- 
Television is a medium because anything well done is rare. -- attributed
to both Fred Allen and Ernie Kovacs

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-09 Thread Ed Greshko
Ed Greshko wrote:
 [EMAIL PROTECTED] wrote:
   
 Cameron Simpson wrote:
 
 On 08Sep2008 21:04, Kevin J. Cummings [EMAIL PROTECTED]
 wrote:
   
 Alan Evans wrote:
 
 On Mon, Sep 8, 2008 at 6:40 AM, Steven Tardy [EMAIL PROTECTED]
 wrote:
   
 kwhiskerz wrote:
 man hostid
 
 On my Fedora 9...
 $ hostid
 

 Now I haven't bothered to check any other machines, but my initial
 impression is that this is not going to work...
   
 I just checked the hostids on my 2 primary machines on the same
 local  network.  They just seem to be encodings of the machine's IP
 addresses.  And since both are PC class machines, the addresses look
 to be syllable swapped (but not byte swapped).

 192.168.6.94 and 192.168.6.106
 a8c05e06 and a8c06a06

 So, I have to ask, does the machine you tried it on have an IP address?
 
 So, let us turn to the docs: man hostid says:

   hostid - print the numeric identifier for the current host
   [...]
   The full documentation for hostid is maintained as  a  Texinfo  manual
   [...]

 Gah. I hate this info-so-no-f'n-man-page rubbish!
 But let's go: info hostid:
 21.4 `hostid': Print numeric host identifier.
   =
   `hostid' prints the numeric identifier of the current host in
   hexadecimal.  This command accepts no arguments.  The only options are
   `--help' and `--version'.  *Note Common options::.
  For example, here's what it prints on one system I use:
$ hostid
1bac013d
On that system, the 32-bit quantity happens to be closely related
 to the
system's Internet address, but that isn't always the case.

 Gah! Again!

 I don't think I'd rely on hostid for anything:-(

 Cheers,
   
 Hi,

 seeing the same (using dhcp for getting an ip address):

 [EMAIL PROTECTED] [backes]: hostid
 

 [EMAIL PROTECTED] [backes]: ifconfig
 eth0  Link encap:Ethernet  HWaddr 00:0C:76:C0:40:36
   inet addr:192.168.179.182  Bcast:192.168.179.255
 Mask:255.255.255.0
   UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
   RX packets:284 errors:0 dropped:0 overruns:0 frame:0
   TX packets:256 errors:0 dropped:0 overruns:0 carrier:0
   collisions:0 txqueuelen:1000
   RX bytes:86392 (84.3 KiB)  TX bytes:25620 (25.0 KiB)
   Interrupt:22 Base address:0x2000

 Not seeing this effect on systems without dhcp usage.

 Regards

 
 FYI, the hostid does not use information from ifconfig.  It looks for a
 match between hostname -s and information in /etc/hosts.  It then uses
 the IP address contained there.  No match then hostid returns .

   
Oooop...

Correction.

It uses hostname for the matchnot hostname -r

Also, it will take the info in /etc/hosts first and if no match will do
a DNS lookup.


-- 
He knew the tavernes well in every toun. -- Geoffrey Chaucer

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-09 Thread Bill Davidsen

Alan Evans wrote:

On Mon, Sep 8, 2008 at 6:40 AM, Steven Tardy [EMAIL PROTECTED] wrote:

kwhiskerz wrote:

Is there a way a script can determine which computer it is running on and
refuse to run if it is on the wrong computer?



man hostid


On my Fedora 9...

$ hostid


Now I haven't bothered to check any other machines, but my initial
impression is that this is not going to work...


Was there some reason you couldn't use the UUID script I posted?

--
Bill Davidsen [EMAIL PROTECTED]
  We have more to fear from the bungling of the incompetent than from
the machinations of the wicked.  - from Slashdot

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-08 Thread Steven Tardy

kwhiskerz wrote:

This is OT, but perhaps someone knows an answer.

Is there a way a script can determine which computer it is running on and 
refuse to run if it is on the wrong computer?


if [ some case ]; then
 run
else
 don't run
fi


man hostid

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-08 Thread Alan Evans
On Mon, Sep 8, 2008 at 6:40 AM, Steven Tardy [EMAIL PROTECTED] wrote:
 kwhiskerz wrote:
 Is there a way a script can determine which computer it is running on and
 refuse to run if it is on the wrong computer?

 man hostid

On my Fedora 9...

$ hostid


Now I haven't bothered to check any other machines, but my initial
impression is that this is not going to work...

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-08 Thread Kevin J. Cummings

Alan Evans wrote:

On Mon, Sep 8, 2008 at 6:40 AM, Steven Tardy [EMAIL PROTECTED] wrote:

kwhiskerz wrote:

Is there a way a script can determine which computer it is running on and
refuse to run if it is on the wrong computer?



man hostid


On my Fedora 9...

$ hostid


Now I haven't bothered to check any other machines, but my initial
impression is that this is not going to work...



I just checked the hostids on my 2 primary machines on the same local 
network.  They just seem to be encodings of the machine's IP addresses. 
 And since both are PC class machines, the addresses look to be 
syllable swapped (but not byte swapped).


192.168.6.94 and 192.168.6.106
a8c05e06 and a8c06a06

So, I have to ask, does the machine you tried it on have an IP address?

--
Kevin J. Cummings
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
Registered Linux User #1232 (http://counter.li.org)

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread Luciano Rocha
On Sat, Sep 06, 2008 at 02:27:27AM -0600, kwhiskerz wrote:
 This is OT, but perhaps someone knows an answer.
 
 Is there a way a script can determine which computer it is running on and 
 refuse to run if it is on the wrong computer?
 
 if [ some case ]; then

if [ $(hostname -s) = puter ]; then
  echo running
fi

Or, for multiple cases:

case $(hostname -s) in
  ws*)
do_something
;;
  db*|app*)
do_other
;;
esac

-- 
lfr
0/0


pgp2CXYlUmOh1.pgp
Description: PGP signature
-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

Re: Script Test [OT]

2008-09-06 Thread Dennis Kaptain
  if [ some case ]; then

 
 if [ $(hostname -s) = puter ]; then
   echo running
 fi


I'd check how the hostname command runs on your computer,
See what happens on my F8 system:

[EMAIL PROTECTED] ~]$ hostname
confianza
[EMAIL PROTECTED] ~]$ hostname -s
localhost
[EMAIL PROTECTED] ~]$ 

the -s option returns 'localhost' so it will never = the name of your computer.

Dennis 


__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.yahoo.com.mx/ 

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread kwhiskerz
The problem is that both computers return hostname = localhost, so that won't 
work. IP address is not always possible, as the network might not be up, 
especially on the laptop.

How would I check the HWaddress (MAC)?

As ifconfig returns a whole list of things:

1.How can I isolate just 00:xx:xx:xx:xx:xx in order to make a comparision?
2.How do I make this comparison in bash? I guess this value must be a string?

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread kwhiskerz
A suggestion I found on the net is to test for the value of md5sum 
/etc/passwd. Now, does this stay the same, even if a password is added or 
changed? Is it unique to a computer? And also, how do I isolate the number and 
strip off the space and /etc/passwd from the result?

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread Patrick O'Callaghan
On Sat, 2008-09-06 at 11:54 -0600, kwhiskerz wrote:
 The problem is that both computers return hostname = localhost, so that won't 
 work. IP address is not always possible, as the network might not be up, 
 especially on the laptop.
 
 How would I check the HWaddress (MAC)?
 
 As ifconfig returns a whole list of things:
 
 1.How can I isolate just 00:xx:xx:xx:xx:xx in order to make a comparision?

/sbin/ifconfig eth0|awk 'NR==1 {print $5}'

(adjust for your primary interface name). Note that this isn't
identifying the machine, it's identifying a network interface, but that
may be good enough for your purpose.

 2.How do I make this comparison in bash? I guess this value must be a string?

if [ $(/sbin/ifconfig eth0|awk 'NR==1 {print $5}') = 00:16:76:C2:87:D2 ]
then
echo yes
else
echo no
fi

poc

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread Les Mikesell

kwhiskerz wrote:
The problem is that both computers return hostname = localhost, so that won't 
work. IP address is not always possible, as the network might not be up, 
especially on the laptop.


How would I check the HWaddress (MAC)?

As ifconfig returns a whole list of things:

1.How can I isolate just 00:xx:xx:xx:xx:xx in order to make a comparision?


Just grep for it, you only need to verify that it is there, not isolate it.


2.How do I make this comparison in bash? I guess this value must be a string?


Use grep's return status instead of doing things the shell doesn't does 
as well.



if ! ifconfig eth0 | grep -q 00:xx:xx:xx:xx:xx
 then
 echo 'wrong box'
 exit 1
fi

..rest of script..


You could also find this value in /etc/sysconfig/network-scripts/ifcfg-eth0

--
  Les Mikesell
   [EMAIL PROTECTED]

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread Cameron Simpson
On 06Sep2008 12:01, kwhiskerz [EMAIL PROTECTED] wrote:
| A suggestion I found on the net is to test for the value of md5sum 
| /etc/passwd.

That's horrible. Unreliable, etc.

| Now, does this stay the same, even if a password is added or 
| changed?

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 [EMAIL PROTECTED] in
[EMAIL PROTECTED])
  # my laptop ...
  ...
  ;;
  esac

and so forth.

Cheers,
-- 
Cameron Simpson [EMAIL PROTECTED] DoD#743
http://www.cskk.ezoshosting.com/cs/

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

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread kwhiskerz
I will see if I can make the HWaddr test work.

Thanks, those are great suggestions.

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread Bill Davidsen

kwhiskerz wrote:
The problem is that both computers return hostname = localhost, so that won't 
work. IP address is not always possible, as the network might not be up, 
especially on the laptop.


How would I check the HWaddress (MAC)?

As ifconfig returns a whole list of things:

1.How can I isolate just 00:xx:xx:xx:xx:xx in order to make a comparision?
2.How do I make this comparison in bash? I guess this value must be a string?


Wrong approach (that means I don't know how to do it reliably).

Try this instead, it needs to be run as root:
  #!/bin/bash
  # get the root device
  rt_dev=$(df / | sed -n '2s/ .*//p'
  # get the UUID in a shell variable
  fsid=$(dumpe2fs -h $rt_dev | sed -n '/UUID:/s/.*: *//p')
  # now you can test it against one or more systems
  # if they NFS mount their root like dickless workstations
  # you have to test something else like /tmp


--
Bill Davidsen [EMAIL PROTECTED]
  We have more to fear from the bungling of the incompetent than from
the machinations of the wicked.  - from Slashdot

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines


Re: Script Test [OT]

2008-09-06 Thread kwhiskerz
Tried it on both computers. Works great! Neither will run the other's script.

Fantastic!

THANKS :-)

-- 
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines