What can I do in order to get the computer name on Raspbian Linux?Strange.
How very strange....What can I do in order to get the computer name on Raspbian Linux?Strange.
What does echo $HOSTNAME give you in a console?
For me it gives the hostname on a RPI.
Nobody knows everything:
The correct way to get the hostname in Linux is
hostname
Again and again:Why? because I'm telling you that the hostname executable is not a reliable way to get the hostname?
The blind man talks about the color.
Winni
If the hostname is overriden by some daemon (yellow pages or whatever), then it doesn't reflect that.
Note that is just what I remember from what I read over the years, I don't have real experience with such setups.
This function is also in the Unix unit, anyone knows if theres a difference?There is no GetHostName in linux unit, it is in
So... Use the GetHostName function from the linux unit.
http://porthos.ist.utl.pt/docs/fpc/units/node288.html
What happens if you use baseunix or unix unit like suggested.So... Use the GetHostName function from the linux unit.Does not work either...
http://porthos.ist.utl.pt/docs/fpc/units/node288.html
I did this:
...
But when I try to compile this I get the error:
logagi.pas(285,42) Error: Identifier not found "GetHostName"
I did not know about the set command but it seems like it outputs what the env command does PLUS a whole lot more like something that looks like program code.If the hostname is overriden by some daemon (yellow pages or whatever), then it doesn't reflect that.
Note that is just what I remember from what I read over the years, I don't have real experience with such setups.
I tried to raise that for discussion a couple of months ago. A number of Linux distreaux still try to use YP by default, even if not installed.
Bo, you /do/ know about the "set" command that allows you to see what shell variables are defined, don't you?
MarkMLl
That is not what was suggested, the uses that was suggested was linux and that failed.What happens if you use baseunix or unix unit like suggested.So... Use the GetHostName function from the linux unit.Does not work either...
http://porthos.ist.utl.pt/docs/fpc/units/node288.html
I did this:
...
But when I try to compile this I get the error:
logagi.pas(285,42) Error: Identifier not found "GetHostName"
Does that contain GetHostName?
Hi!Well, I do not know on what system my program is running and this is obviously a hack to edit the environment.
As I told before:
If you got a funny uncivilized Linux then first put the hostname into the environment:And everything is done.
env HOSTNAME=MySweetRaspi
Winni
Seems like I really have to open a file on the disk (cat /etc/hostname) in order to read the hostname from it...I don't know about /etc/hostname, but /proc/sys/kernel/hostname is a pseudofile, meaning it a file path that does not correspond to a real file on the disk, but one that the operatingsystem handles specially. Meaning not a single disk operation will be executed when reading/writing to such files. So it is orders of magnitude faster than normal file accesses and should be only be slightly slower than the respected posix function (GetHostname) (probably around a factor of 3 times slower, because you need 3 system calls instead of one, fopen, fread and fclose).
Hi!Well, I do not know on what system my program is running and this is obviously a hack to edit the environment.
As I told before:
If you got a funny uncivilized Linux then first put the hostname into the environment:And everything is done.
env HOSTNAME=MySweetRaspi
Winni
Where should that be done?
And it feels like a chicken and egg complication...
So... Use the GetHostName function from the linux unit.
http://porthos.ist.utl.pt/docs/fpc/units/node288.html
So... Use the GetHostName function from the linux unit.
http://porthos.ist.utl.pt/docs/fpc/units/node288.html
There is still one in unix.pp.So... Use the GetHostName function from the linux unit.
http://porthos.ist.utl.pt/docs/fpc/units/node288.html
Not there anymore. Any idea where is it?