Hey, Uncle, I have some trouble with your script on my new machine. It used to run fine on my old computer (same distro (Debian squeeze), same architecture (amd64))
Unclefragger wrote:
just paste this command into a terminal:
Code:
echo `uptime|grep days|sed 's/.*up ([0-9]*) day.*/1/10+/'; cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df -P -k | grep -v '(1k|1024)-blocks' | awk '{if ($1 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15+70";}'`|bc|sed 's/(.$)/.1 cm/'
and tell us your score ;)
I guess my new machine has to big a brother for this script and the scrips can't handle it:
Code:
natirips@nati-desk:~$ echo `uptime|grep days|sed 's/.*up ([0-9]*) day.*/1/10+/'; cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df -P -k | grep -v '(1k|1024)-blocks' | awk '{if ($1 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15+70";}'`|bc|sed 's/(.$)/.1 cm/'
sed: -e izraz #1, znak 27: unknown option to `s'
5464
natirips@nati-desk:~$
So I tried to fix it (I _think_ the last one is the closest to what it should be):
Code:
natirips@nati-desk:~$ echo `uptime|grep days|sed 's=.*up ([0-9]*) day.*=1=10+/'; cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df -P -k | grep -v '(1k|1024)-blocks' | awk '{if ($1 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15+70";}'`|bc|sed 's/(.$)/.1 cm/'
sed: -e izraz #1, znak 27: unknown option to `s'
5488
natirips@nati-desk:~$ echo `uptime|grep days|sed 's=.*up ([0-9]*) day.*=1=10+='; cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df -P -k | grep -v '(1k|1024)-blocks' | awk '{if ($1 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15+70";}'`|bc|sed 's/(.$)/.1 cm/'
sed: -e izraz #1, znak 27: unknown option to `s'
5488
natirips@nati-desk:~$ echo `uptime|grep days|sed 's=.*up ([0-9]*) day.*/1=10+='; cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df -P -k | grep -v '(1k|1024)-blocks' | awk '{if ($1 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15+70";}'`|bc|sed 's/(.$)/.1 cm/'
5488
natirips@nati-desk:~$ echo `uptime|grep days|sed 's=.*up ([0-9]*) day.*/1=10+='; cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df -P -k | grep -v '(1k|1024)-blocks' | awk '{if ($1 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15+70";}'`|bc|sed 's/(.$)/.1 cm/'
5488
natirips@nati-desk:~$ echo `uptime|grep days|sed 's=.*up ([0-9]*) day.*=1/10+='; cat /proc/cpuinfo|grep '^cpu MHz'|awk '{print $4"/30 +";}';free|grep '^Mem'|awk '{print $3"/1024/3+"}'; df -P -k | grep -v '(1k|1024)-blocks' | awk '{if ($1 ~ "/dev/(scsi|sd)"){ s+= $2} s+= $2;} END {print s/1024/50"/15+70";}'`|bc|sed 's/(.$)/.1 cm/'
5488
natirips@nati-desk:~$
But I can't figure out the first "sed":
man sed wrote:
Code:
s/regexp/replacement/
Attempt to match regexp against the pattern space. If success‐
ful, replace that portion matched with replacement. The
replacement may contain the special character & to refer to
that portion of the pattern space which matched, and the spe‐
cial escapes \1 through \9 to refer to the corresponding match‐
ing sub-expressions in the regexp.
So it should have 3 separators, but yours has 4:
Code:
sed 's/.*up ([0-9]*) day.*/1/10+/'