You were correct Scrutinizer, it was the spacing. I did read the error message but could not make sense of it until the folly of my ways was made clear to me...
So that part of the script is now fully functional but I cannot get permissions on the .gvfs to be read from superuser. I have read that this is a fuse mount point, and therefor not located in /etc/fstab. so When I unmount it, chmod and try to mount again... it bombs out not knowing where to look. There are a few more chapters on the tutorial I am working on, but before I complete them, I would like o understand my current issue. My first post got me scolded by a mod for not using correct code tags, so I am going to try this again with the entire script.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Code:
#!/bin/bash
# systeminfo - A script to produce an HTML file with system info.
##### Constants
TITLE="System Information for $HOSTNAME"
RIGHT_NOW=$(date +"%x %r %Z")
TIME_STAMP="Updated on $RIGHT_NOW by $USER"
##### Functions
function press_enter
{
echo ""
echo -n "Press Enter to continue"
read
clear
}
function system_info
{
echo "<h2>System release info</h2>"
echo "<p>Function not yet implimented</p>"
} # end of system_info
function show_uptime
{
echo "<h2>System Uptime</h2>"
echo "<pre>"
uptime
echo "</pre>"
} # end of show_uptime
function drive_space
{
echo "<h2>Filesystem space</h2>"
echo "<pre>"
df
echo "</pre>"
} # end of drive_space
# this is the function that requires superuser. I changed the id to 1000 just to see results and it worked, but no dice with root.
function home_space
{
# Only superuser can get this information
if [ "$(id -u)" = "0" ]; then
echo "<h2>Home directory space by user</h2>"
echo "<pre>"
echo "Bytes Directory"
du -s /home/* | sort -nr
echo "</pre>"
fi
} # end of home space
function write_page
{
cat <<- _EOF_
<html>
<head>
<center>
<title>$TITLE</title>
</center>
</head>
<body>
<center>
<h1>$TITLE</h1>
<p>$TIME_STAMP</p>
$(system_info)
$(show_uptime)
<table border="1">
<tr>
<td>
$(drive_space)
</td>
<td>
$(home_space)
</td>
</table>
</center>
</body>
</html>
_EOF_
}
function usage
{
echo "usage: systeminfo [[[-f file ] [-i]] | [-h]]"
}
press_enter
##### Main
interactive=
filename=~/system_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
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
# Write page
write_page > $filename
Dear All,
I'm trying to write a shell script that continously checks a certain folder. When a file is placed in the directory securely copies the file to another server.
I've got the secure copying working, but I don't know how to contiously check a directory for a new file and then use that... (3 Replies)
I have a folder with lots of file. e.g. a.txt, b.txt, c.txt.... I want to put these files from the source directory and place them in a destination directory in a specific order, such as /destination/a/a.txt, /destination/b/b.txt, /destination/c/c.txt, ......
Please help. Thx :confused: (3 Replies)
Hi,
I was using AIX - ksh shell , and inorder to debug shell script I used set -vx to echo all the commands which are being executed.
Can anybody tell me the corresponding method in HP-UX - in tcsh shell.
Regards
Shihab (1 Reply)
Hi All,
How to debug the unix shell script? which one is the best way to do the debuging ?
suggession would be appreciate
Regards,
Siva P
Bangalore (2 Replies)
Hello, Some one asked me in the inteview.... The question is,
How do we debug the schell script before even running..... Interviewer
told me one clue... There is SET command to accomplish this... Can any
one tell me what kind of set commands.... Thanks. (2 Replies)
. ./testFile.sh
url=http://ichart.finance.yahoo.com/table.csv?s= suf=&d=5&e=9&f=2009&g=d&a=1&b=4&c=1999&ignore=.csv
wget $url$s1$suf;
sleep 10;
cat header.txt > $s1.txt;
chmod 777 $s1.txt;
sed '1d' table.csv?s\=$s1 >> $s1.txt;
rm -Rf table*
Very new at shell scripting as you can see... (3 Replies)
Hello,
I'm new to Sheel script and I need your help for a script I need to develop (for me).
Indead, I have a software which log all entry from internet and save it in text file.
But, the log is practically unreadable because every 256 characters jump to a new line (even if the message is... (5 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
"Create a shell script that changes the selected word to another word in all files from selected archive. The... (1 Reply)
1. The problem statement, all variables and given/known data:
Arguments:
http://farm9.staticflickr.com/8070/8212131370_8b6e8c10c5_c.jpg
I am given these three arguments. $1, $2, $3
The first argument is the path to a directory.
So, how would I go into the directory and compare files?
I... (5 Replies)
hi all
only the weirdest thing happened with me just now. I was debugging a shell script and I found that a step that was supposed to execute later was getting executed prior to another step for no reason. You know any ?
i mean have a look at the following command-
here it tries to grep... (7 Replies)