If you are required to retrieve the gateway serial number from an IOx application, environment variables set by the Cisco Application Framework (CAF) are automatically set in the execution environment in the /data/.env file.
You can access this file from your IOx application directly, or invoke it to set all the variables as environment variables, such as:
/ # source /data/.env
/ # echo $CAF_SYSTEM_SERIAL_ID
FGL23362022
To see all the variables available in an IOx container, this can be done by accessing the console with the ioxclient utility. The following command (to get console to the application called iox-serial) and then list all the variables:
etychon@squeeze:~/iox/iox-serial$ ioxclient app con iox_serial
Currently active profile : default
Command Name: application-console
Console setup is complete..
Running command : [ssh -p 2222 -i iox_serial.pem appconsole@192.168.2.231]
/ # cat /data/.env
#!/bin/sh
export CAF_APP_PERSISTENT_DISK_SIZE_KB=102400
export CAF_APP_MEMORY_SIZE_KB=51200
export CAF_SYSTEM_PRODUCT_ID=IR829M-2LTE-EA-EK9
export CAF_SYSTEM_NAME=IR800
export CAF_SS_PORT=9443
export CAF_APP_APPDATA_DIR=/data/appdata
export CAF_APP_CONFIG_DIR=/data
export CAF_SS_IP_ADDR=192.168.1.6
export CAF_APP_CORE_DIR=/tmp/cores
export CAF_APP_LOG_DIR=/data/logs
export CAF_SYSTEM_SERIAL_ID=FGL23362022
export CAF_APP_PERSISTENT_DIR=/data
export CAF_APP_CPU_SHARES=342
export CAF_APP_ID=iox_serial
export CAF_APP_USERNAME=root
export HOST_DEV1=/dev/ttyACM0
export CAF_SYSTEM_UUID=7581eb7b-8c04-4412-b2bb-503598f06a72/
To learn more about these variables check the "Environment Variables" section of Cisco IOx DevNet Documentation: https://developer.cisco.com/docs/iox/#!application-development-concepts/application-development-concepts