Results 1 to 1 of 1
Hey everyone! I need help once again, working on a script and cant seem to get any further then I am now. Here is what needs to do be and ...
- 03-14-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 9
Menu script with functions HELP!!!!
Hey everyone! I need help once again, working on a script and cant seem to get any further then I am now. Here is what needs to do be and here is what I have done so far.
Have the menu loop to allow user to continue to select items.
Check to see if output html file pathname is valid. If not, display a stderr message
and terminate the shell script with and FALSE exit status.
*Add Text
- Prompt the user for a single tag letter: t (for <title>), h(for <h1>),p (for <p>),b (for <blockquote>).
- Next, prompt the user for text to enter for that tag.
- When text is entered, store that text in a temporary file that represents that tag.
- This temporary file should be allowed to "grow" in case the user wants to add more text to that file at a later time...
- You can assume that if you add more text into either the paragraph, blockquote, heading, or title the text accumulates in the temporary file to be used at the same time. Thus when you publish the webpage, it only uses the combined contents of these temporary files to display those tags (i.e. don't create multiple occurences of paragraphs, blockquotes, headings, or titles - only display one occurance of paragraph, blockquote, heading, and title).
*Clear all Text
- Erase content from existing temporary files representing the tags (eg. t, h, p, b).
*Publish Webpage
- Assemble all of the contents in the temporary files representing tags (eg. t, h, )
and use them to insert in a basic HTML file.
- The filename to use for the HTML was either the argument after your shell script, or the value that was prompted if you issued your shell script without an argument...
- This file MUST be placed in the ~/public_html directory for the user in order to be published.
HTML file MUST have the following permissions:
-rwxr-xr-x
*Exit
- Terminate the shell script
- NOTE: Do NOT remove or clear temporary file contents representing tags, since the user may want to run the command again, and add more text...
This is what I have so far.
#!/bin/bash
if [ "$#" -ge 2 ]; then
echo "Command requires zero or one argument" >&2
echo "USAGE:./qpres.bash [httml_file_pathname]" >&2
exit
elif [ ! -f $1 ]; then
echo "Error: Html file \"$1\" does NOT exist " >&2
exit 1
elif [ "$#" -eq 0 ]; then
read -p "Enter output file pathname: $file " >&2
else
file=mypage.html
fi
clear
cat <<+
*======================================*
*======================================*
--------- <-QUICK PRESS MENU-> ---------
****************************************
****************************************
1. Add Text
2. Clear all Text
3. Publish webpage
4. Exit
+
read -p "Enter a menu item (1,2,3,4): " choice
case $choice in
#Depending on the users choice, it will display a different output msg.
1) read -p "Please enter a single tag letter: t, h, p, b" tletter
;;
2) echo "Item chosen: Clear all Text "
;;
3) echo "Webpage published "
;;
4) echo "Goodbye"
exit 0
;;
*) echo "Invalid Selection: $choice." >&2
;;
esac


Reply With Quote