>I am building up a filename in a C program. I would like to
>include the host name (computer name) of the machine that the script
>runs on. The script will be run on many different (all same OS and
>version) machines, so the host name will change depending on which
>machine the script is executed on.
>
>There is a DOS command "hostname" that returns the host name to the
>screen.
>
>I have tried using it directly in my C program with no
>success. My program thinks that hostname is a variable and
>stops because it has not been declared. I have also tried using
>hostname as the argument for the system command -> system(hostname).
>This also does not work.
>
>I am able to use the DOS command, mkdir, directly in my program. I
>was hoping to be able to do the same with hostname.
>
>I would like to capture the host name in a string variable in my
>script.
Does the GetComputerName() or gethostname() APIs help any? Both are useful
if all you need is the name for using it on a LAN. Not always accurate,
but if you own all of the PCs they are quick-and-dirty hacks. There are
more complex solutions, of course.
Thomas J. Hruska
[EMAIL PROTECTED]
Shining Light Productions
Home of the Nuclear Vision scripting language and ProtoNova web server.
http://www.slproweb.com/
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.