Help - Search - Members - Calendar
Full Version: Create simple data entry script
Linuxhelp > Support > Technical Support
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
while [ $looptest = y ]
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" ]
clear; exit
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" > " " ]
echo "$title:$artist:$album" >> $musicfile
tput cup 12 33; read looptest
if [ "$looptest" = "q" ]
clear; exit
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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.