Alright, I am still having some issues and will provide all of the info I can.
First, when included in my script i get 0.
This is where i echo out the awk file:
Code:
echo "/BIOS-e820/&&/usable/{" > ram.awk
echo ' for(i=1;i<=NF;i++){' >> ram.awk
echo ' if($i ~ /[0-9a-fA-F]{16}/){' >> ram.awk
echo ' "echo \"scale=10;ibase=16;"toupper(gensub(/0?[xX]?([0-9a-fA-F]{16})/,"\\1","1",$i))"\"|bc -l"|getline tmp' >> ram.awk
echo ' if(a[NR]){' >> ram.awk
echo ' a[NR]+=tmp' >> ram.awk
echo ' total+=a[NR]' >> ram.awk
echo ' }else{' >> ram.awk
echo ' a[NR]-=tmp' >> ram.awk
echo ' }' >> ram.awk
echo ' }' >> ram.awk
echo ' }' >> ram.awk
echo ' }' >> ram.awk
echo 'END{' >> ram.awk
echo ' print total' >> ram.awk
echo '}' >> ram.awk
This is where i call the awk file:
Code:
RAM=dmesg | awk --re-interval -f ram.awk
And finally this is where I print the RAM variable (there is no other manipulation of the RAM variable anywhere else in the script:
Code:
echo "Total space on drive (in Mb): $SPACE"
echo "Remaining space available (in Mb): $SPACE3"
echo "System RAM (in Mb): $RAM"
echo -n "Space allocated for swap (in Mb):"
read VAR3
and the output is 0
. Strangely, when first testing i had accidentally included an = in the call (RAM=dmesg | awk --re=interval -f ram.awk) and it provided me with 2914.13. Not sure if that means anything or not though.
Testing on the puppy linux live cd:
Contents of ram.awk: (srry bout the formatting, it didnt like the copy paste into the shell, but other than the tabs being off it didn't look like it changed anything)
Code:
/BIOS-e820/&&/usable/{
for(i=1;i<=NF;i++){
if($i ~ /[0-9a-fA-F]{16}/){
"echo \"scale=10;ibase=16;"toupper(gensub(/0?[xX]?([0-9a-fA-F]{16})/
if(a[NR]){
a[NR]+=tmp
total+=a[NR]
}else{
a[NR]-=tmp
}
}
}
}
END{
print total
}
The output:
sh-4.1# dmesg | awk --re-interval -f ram.awk
3084648448
Which is not 4 gig
.
Here is the output of dmesg from the puppy linux live cd:
Code:
sh-4.1# dmesg | grep e820
BIOS-e820: 0000000000000000 - 000000000009b800 (usable)
BIOS-e820: 000000000009b800 - 00000000000a0000 (reserved)
BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved)
BIOS-e820: 0000000000100000 - 00000000b7ec0000 (usable)
BIOS-e820: 00000000b7ec0000 - 00000000b7ee0000 (reserved)
BIOS-e820: 00000000b7ee0000 - 00000000b7ee3000 (ACPI NVS)
BIOS-e820: 00000000b7ee3000 - 00000000b7ef0000 (ACPI data)
BIOS-e820: 00000000b7ef0000 - 00000000b7f00000 (reserved)
BIOS-e820: 00000000b8000000 - 00000000c0000000 (reserved)
BIOS-e820: 00000000f0000000 - 00000000f4000000 (reserved)
BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
e820 update range: 0000000000000000 - 0000000000010000 (usable) ==> (reserved)
ACPI: HPET id: 0x10de8201 base: 0xfeff0000
sh-4.1#
Finally, i tested this on the already installed cent os (referred to previously in the post as HD installed)
contents of ram.awk:
Code:
/BIOS-e820/&&/usable/{
for(i=1;i<=NF;i++){
if($i ~ /[0-9a-fA-F]{16}/){
"echo \"scale=10;ibase=16;"toupper(gensub(/0?[xX]?([0-9a-fA-F]{16})/,"\\1","1",$i))"\"|bc -l"|getline tmp
if(a[NR]){
a[NR]+=tmp
total+=a[NR]
}else{
a[NR]-=tmp
}
}
}
}
END{
print total
}
[root@localhost ~]# dmesg | awk --re-interval -f ram.awk
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
So I checked the version of both bash and awk:
GNU bash, version 3.2.25(1)-release (i686-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 Free Software Foundation.
My thoughts: Kinda lost right now as my understanding of whats going on in that awk script = 0. It is quite possible I have screwed something up in the script by copy/paste or echoing it out. It is also possible that I am not echoing it out early enough in the script (kickstart is a picky thing), but i am doing it before i call it in the %pre section. I would be more inclined to experiment along those lines if the output from the live cd was correct. Other than that, because i don't know how the script is working, I feel quite lost. I think my next trouble shooting attempt is going to be to call dmesg | grep e820 in my script so i can look at the output of that from the installation kernel, but that will have to wait until tomorrow.
Strange that this is the part of my script I am hung on as I thought this part would be much easier than the rest, but everything else is already done
Any further assistance or suggestions anyone can provide would be greatly appreciated.
Thanks