#!/bin/sh
#Put file name we're saving the info above to in a var called fname
fname=./names.dat
# If the file does not exist create it
[ ! -f $fname ] && $fname
# Display the menu
clear
echo "\n\t\tThe Shell Programming Database"
echo "\t\t\tMain Menu"
echo "\nWhat do you want to do?\n"
echo "\t1. Create records"
echo "\t2. View records"
echo "\t3. Search for records"
echo "\t4. Delete records that match a pattern"
echo
# Ask for an answer
echo -n "Answer?"
read ans junk
# Decide what to do
case "$ans" in
# read in the contact details from the keyboard
1)
echo "Please enter the following details:"
echo
#Ask user for name and address
echo -n "Please enter your first name: "
read first
echo -n "Please enter your surname: "
read sur
echo -n "Enter your street address: "
read street
echo -n "Enter your city: "
read city
echo -n "Enter you state: "
read state
echo -n "Finally your zip code: "
read zip
# Append info entered to names.dat
echo $first:$sur:$street:$city:$state:$zip >> $fname
;;
2)
# Show what's in the file
echo
echo Here are the current contacts recorded:
echo
(cat $fname | more)
# count and tell user the number of these records stored
echo
echo There are `cat $fname | wc -l` contacts in the database.
;;
3)
echo Seach not finished
;;
4)
echo Search not finshed
;;
*)
echo "Really?^G"
;;
esac
Bash Scripting Problems, Maybe deprecated code?
Page 1 of 19 Replies - 3293 Views - Last Post: 13 March 2011 - 01:51 AM
#1
Bash Scripting Problems, Maybe deprecated code?
Posted 08 March 2011 - 08:46 PM
Been working out of some Bash Scripting videos. Don't know why this code doesn't seem to run, even though I followed the instructions to the tee. The videos are a little dated though. But the only stuff not working are the \t \n and ^G.
Replies To: Bash Scripting Problems, Maybe deprecated code?
#2
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 11 March 2011 - 05:28 PM
Try using the -e flag.
to allow special characters
echo -e "Words Words \t Words"
to allow special characters
#3
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 11 March 2011 - 10:40 PM
That worked! Thank You!
#4
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 12 March 2011 - 06:19 PM
I may have spoke too soon. It worked on \t and \n but not the ^G. I researched the man page for echo and saw I probably should have used \a instead.
While this does run instead of showing up in the text, there's no alert bell?
Quote
\a alert (BEL)
While this does run instead of showing up in the text, there's no alert bell?
#5
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 12 March 2011 - 10:04 PM
Does your system have a bell?
#6
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 12 March 2011 - 10:55 PM
Looks like it to me...
# modprobe -l | grep pcspkr /lib/modules/2.6.35.8/kernel/drivers/input/misc/pcspkr.ko
This post has been edited by Israel: 12 March 2011 - 11:34 PM
#7
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 12 March 2011 - 11:02 PM
Can you cause an audio beep with any other program? Either a wrong key press in Bios, or interrupt the bootup sequence & fill the keyboard buffer.
#8
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 12 March 2011 - 11:44 PM
Yeah, this is a new distro for me so I checked. I did get a little beep when hit some input during the boot sequence.
#9
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 13 March 2011 - 12:30 AM
I know that there is a device for the sound card, /dev/audio is usually a symbolic link to the sound card block device. I think that there is (or used to be) one for the system speaker as well. Maybe there is a kernel modules, something like pcspkr?
Depending on the distro, they may have done away with such legacy hardware devices.
Depending on the distro, they may have done away with such legacy hardware devices.
#10
Re: Bash Scripting Problems, Maybe deprecated code?
Posted 13 March 2011 - 01:51 AM
I did post the path to my module for pcspkr, but I didn't know it was linked in /dev. Apparently it doesn't exist there in this distro. Whatever the case I think I'll let it die for now. This isn't for work or school, I just wanted to make sure I was learning it right. Thanks for your help.
This post has been edited by Israel: 13 March 2011 - 01:55 AM
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|