Linux+ episode "Shells and Scripting" issue
-
I was watching and following along. In a VM running centOS I ran in to issues with the first function you wrote. so in vi I edited my root .bashrc as such
function sysinfo()
echo -e "\nKernel Info:" ; uname -a
echo -e "\nOS Version:" ; cat /etc/centos-release
echo -e "\nSystem Uptime" ; uptime
echo -e "\nMemory Utilization:" ; free -m
echo -e "\nFile System Utilization:" ; df -h
But when i log out and log back into root it produces the following error
-bash:/root/.bashrc line 11: syntax error near unexpected token 'echo'
-bash:/root/.bashrc line 11: ' echo -e "\nKernel Info:" ; uname -a"
-bash-4.2# _
so it drops me imedietly into bash rather then root?
any help would be appreciated. -
Christopher,
It might be our forums, but it looks like you are missing some {} brackets in your function definition. Here is the sample I used in the show:function sysinfo() { echo -e "\nKernel Information:" ; uname -a echo -e "\nOS Version:" ; cat /etc/centos-release echo -e "\nSystem Uptime:" ; uptime echo -e "\nMemory Utilization:" ; free -m echo -e "\nFilesystem Utilization:"; df -h }
Give that a shot and let me know how it goes.
Don Pezet
Host, ITProTV -
Thanks Don,
nope i was missing the fancy { . couldn't see it on the edge of my console tv! thanks for getting back to me so soon.
-chris