Question: My script doesnt run ( Linux).. can someone help my please? #!/bin/bash # sysinfo_page - A script to produce a system information HTML file #####
My script doesnt run ( Linux).. can someone help my please? $TITLE
#!/bin/bash
# sysinfo_page - A script to produce a system information HTML file
##### Constants
TITLE="System Information for $HOSTNAME"
RIGHT_NOW=$(date +"%x %r %Z")
TIME_STAMP="Updated on $RIGHT_NOW by $USER"
##### Functions
system_info()
{
echo "
System release info
" echo "
Function not yet implemented
"} # end of system_info
show_uptime()
{
echo "
System uptime
" echo "
"
uptime
echo ""
} # end of show_uptime
drive_space()
{
echo "
Filesystem space
" echo "
"
df
echo ""
} # end of drive_space
home_space()
{
# Only the superuser can get this information
if [ "$(id -u)" = "0" ]; then
echo "
Home directory space by user
" echo "
"
echo "Bytes Directory"
du -s /home/* | sort -nr
echo ""
fi
} # end of home_space
write_page()
{
# sysinfo_page - A script to produce a system information HTML file
##### Constants
TITLE="System Information for $HOSTNAME"
RIGHT_NOW=$(date +"%x %r %Z")
TIME_STAMP="Updated on $RIGHT_NOW by $USER"
##### Functions
system_info()
{
echo "
System release info
" echo "
Function not yet implemented
"} # end of system_info
show_uptime()
{
echo "
System uptime
" echo "
"
uptime
echo ""
} # end of show_uptime
drive_space()
{
echo "
Filesystem space
" echo "
"
df
echo ""
} # end of drive_space
home_space()
{
# Only the superuser can get this information
if [ "$(id -u)" = "0" ]; then
echo "
Home directory space by user
" echo "
"
echo "Bytes Directory"
du -s /home/* | sort -nr
echo ""
fi
} # end of home_space
write_page()
{
cat <<-_EOF_
$TITLE
$TIME_STAMP
$(system_info)
$(show_uptime)
$(drive_space)
$(home_space)
_EOF_
}
usage()
{
echo "usage: sysinfo_page [[[-f file ] [-i]] | [-h]]"
}
##### Main
interactive=1
filename=~/sysinfo_page.html
while [ "$1" != "" ]; do
case $1 in
-f | --file )
shift
filename=$1
;;
-i | --interactive )
interactive=1
;;
-h | --help ) usage
exit
;;
* )
usage
exit 1
;;
esac
shift
done
# Test code to verify command line processing
if [ "$interactive" = "1" ]; then
response=
echo -n "Enter name of output file [$filename] > "
read -r response
if [ -n "$response" ]; then
filename=$response
fi
if [ -f "$filename" ]; then
echo -n "Output file exists. Overwrite? (y/n) > "
read -r response
if [ "$response" != "y" ]; then
echo "Exiting program."
exit 1
fi
fi
fi
if [ "$interactive" = "1" ]; then
echo "interactive is on"
else
echo "interactive is off"
fi
echo "output file = $filename"
# Write page (comment out until testing is complete)
write_page > $filename
if [ "$interactive" = "1" ]; then
response=
echo -n "Enter name of output file [$filename] > "
read response
if [ -n "$response" ]; then
filename=$response
fi
if [ -f $filename ]; then
echo -n "Output file exists. Overwrite? (y/n) > "
read response
if [ "$response" != "y" ]; then
echo "Exiting program."
exit 1
fi
fi
fi
mail -s "name.html" name@email -s "cjm.html" c-name@email
*** I will update my name and email***
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
