Script 1
#!/usr/local/bin/lua
--
-- script to read the uBoot environment
--
h=assert(io.open('/dev/mtd0ro','rb'))
h:seek('set',655360 + 4)
s=h:read(262144)
h:close()
b,e = s:find('%z%z')
if not b then return end
s=s:sub(1,b)
for k,v in s:gmatch('([^\=]-)=([%Z]+)%z') do
if arg and #arg > 0 then
if arg[1] == k then
io.write(v,'\n')
break;
end
else
io.write(k,'=',v,'\n')
end
end
Script 2
#!/usr/bin/perl -w
#
# script prints the Sheevaplug uBoot environment
# Excuse the my perl
#
open FILE1, '</dev/mtd0ro' or die $!;
binmode FILE1;
my ($buf, $s, $n, $val);
if ($#ARGV == 0) {
$val = $ARGV[0];
}
seek FILE1, 655360 + 4, 0;
$n=read FILE1, $s, 262144;
close FILE1;
if ($n == 262144) {
$s =~ m/(.+?)\0\0/;
$s = $1;
$s =~ s/\000/\n/g;
while ($s =~ m/([\w_]+?)=([^\n]+)\n?/g) {
if ($val) {
if ($val eq $1) {
print "$2\n";
exit 0;
}
}
else {
print "$1=$2\n";
}
}
}