Node and user info example

This example fetches some info about underlying machine and user who started this program.

Compilation

Easiest way to get this example running is to go to examples directory in package root, and run:

$ ./build.sh node_info

build.sh script compiles Ano script to C, copies source files in place and pops up instructions what to do next. Follow them. Check also examples/README for more info.

Preview

; ------------------------------------------------------------------------------
; node_info.ano
;
; To compile:
;
; $ ./build/ano ./examples/node_info/node_info.ano > \
;     engine/dsl_ano.h
; ------------------------------------------------------------------------------
;
@ANO_SCRIPT_NAME		node_info
@ANO_SCRIPT_VERSION		0.0.1
@ANO_SCRIPT_DESCRIPTION	Simple node info fetcher example
;
@ANO_FLAGS_USE_PROTOS		[ ]
@ANO_FLAGS_VAR_NAME_SUBS	[ ]
@ANO_FLAGS_VAR_WARN_UNUSED	[ ]
;
; Copyright © 2016-2026, Jani Salonen <salojan@goto10.co>
; All rights reserved.
;
; This example fetches some info about underlying machine and user starting
; this program.
;

main [exit: 0] {
	print "\nSystem information\n"
	print "------------------\n\n"

	; Get machine info…
	;
	_host_name = node_get_hostname
	_host_id = node_get_hostid

	print "Hostname: " . _host_name . "\n"
	print "Host id: " . _host_id . "\n\n"

	_system = node_get_system
	_release = node_get_release
	_machine = node_get_machine

	print "System: " . _system . "\n"
	print "Release: " . _release . "\n"
	print "Machine: " . _machine . "\n\n"

	; …and user info as well.
	;
	_user_name = node_get_username
	_group_name = node_get_groupname
	_user_id = node_get_userid
	_group_id = node_get_groupid
	_home_dir = node_get_homedir
	_gecos = node_get_gecos

	print "User name: " . _user_name . ", id: " . _user_id . "\n"
	print "Primary group: " . _group_name . ", id: " . _group_id . "\n"
	print "Home directory: " . _home_dir . "\n"
	print "Gecos info: " . _gecos . "\n\n"
}
; ------------------------------------------------------------------------------
; node_info.w2c
;
; To compile:
;
; $ ./build/widget ./examples/node_info/node_info.w2c > \
;     engine/widget_defs.h
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; node_info.m2c
;
; To compile:
;
; $ ./build/menu ./examples/node_info/node_info.m2c > \
;     engine/menu_defs.h
; ------------------------------------------------------------------------------

Copyright © 2026, Jani Salonen <salojan at goto10 piste co>. Piste is finnish word and means dot. All rights reserved.