Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Create simple data entry script
smw79
post Nov 5 2006, 01:03 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 12
Joined: 22-May 06
Member No.: 6,413



I've been attempting to create a simple data entry script through vi editor. I'm not having much luck with it. I"m looking at an example from a book, and they use about 7 entries and I only want to do 3 and I thought it would be the same, just cutting everything down.

I haven't had any luck so far. I don't have any errors when I execute the script, but the cursos is not in the correct position and it doesn't save any entry. Here is the script I'm trying to run, can anyone help me out or tell me what I'm doing wrong????

trap "rm ~/tmp/* 2> /dev/null; exit" 0 1 2 3
musicfile=~/music/music_database
looptest=y
while [ $looptest = y ]
do
clear
tput cup 1 4; echo "Linux Music Database Additions"
tput cup 2 4; echo "=============================="
tput cup 4 4; echo "Title : "
tput cup 5 4; echo "Artist: "
tput cup 6 4; echo "Album: "
tput cup 8 4; echo "Add Another? (y)es or (q)uit: "
tput cup 9 18; read newalbum
if [ "$newalbum" = "q" ]
then
clear; exit
fi
tput cup 5 18; read title
tput cup 6 18; read artist
tput cup 7 18; read album
# Check to see if album is not a blank before you write to disk
if [ "$album" > " " ]
then
echo "$title:$artist:$album" >> $musicfile
fi
tput cup 12 33; read looptest
if [ "$looptest" = "q" ]
then
clear; exit
fi
done
Go to the top of the page
 
+Quote Post
michaelk
post Nov 5 2006, 09:02 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



The "tput cup r c" command moves the cursor to row, column. row meaning up, down and column left right. Your add another albumn question is at row 8 but your moving the cursor to row 9 when reading input. I assume you want to put the cursor at the end of "Add Another? (y)es or (q)uit:". If the A in Add is at column 4 count the number of characters (including spaces ) from A (4) till you get to : and add one. So this value is x in your statement below.

tput cup 8 x; read newalbum

The same goes with your read statements for title, artist and albumn.

As for writing to a file I do not see any problems. Make sure the music directory exists in your home directory.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 14th December 2017 - 09:56 AM