OpenWrt Forum Archive

Topic: Kamikaze Scripting

The content of this topic has been archived on 10 Mar 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi All,
I want to echo my hostname, can someone point out what is wrong with my script to me, please?

#!/bin/sh
. /etc/functions.sh
config_load /etc/config/system
config_get host system hostname
echo
echo "hostname is: $host"
echo
echo "hostname by 2nd method is:"
config_get system hostname


Thanks,

Since your system section is (most likely) not named, you have to first retrieve the assigned name of the section.  I'm lazy and loading mine like this, which uses the assigned name of the first block.  Take a look at your uci command to see what I mean about the assigned name.

config_load system
config_get WAN_NAME ${CONFIG_SECTIONS%% *} hostname

Hi,
netprice, it worked! Thanks, I hope I can get some code to understand what you were driving at.
Thanks.

The discussion might have continued from here.