Graphic Display of CD records

Source: Internet
Author: User
#! /Bin/sh # very simple example shell script for managing a CD collection. # copyright (c) 1996-2007 Wiley Publishing Inc. # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the license, or (at your # option) any later version. # This program is distributed in the ho PES that it will be useful, but # without any warranty; without even the implied warranty of # merchantability or fitness for a participant purpose. see the GNU General # Public License for more details. # You shoshould have written ed a copy of the GNU General Public License along # With this program; if not, write to the Free Software Foundation, Inc. #675 Mass Ave, Cambridge, MA 02139, USA. menu_choice = "" C Urrent_cd = "" title_file = "title. CDB "tracks_file =" tracks. CDB "temp_file =/tmp/CDB. $ trap 'rm-F $ temp_file 'exitget_return () {gdialog -- title "" -- yesno "$1" 9 18 x = $? If [$ x = 0]; then return 0 else return 1 fi} get_confirm () {gdialog -- title "" -- yesno "$ *" 9 18 x = $? While true do case $ X in 0) Exit 0; *) Exit 1 esac done} set_menu_choice () {Rm-F _1.txt if ["cdcatnum "! = ""]; Then gdialog -- title "mini CD manager" -- checklist "Options: -"15 25 3 A" Add new cd "" on "F" find CD "" off "C" count the CDs and tracks in the catalog "" off "R" remove exist cd "" off "U" Update track information for an exist cd "" off "2> _1.txt x =$? If [$ X! = 0]; then Rm-F _1.txt Exit 1 else menu_choice = $ (cat _1.txt) Fi else gdialog -- title "mini CD manager" -- checklist "Options: -"15 25 3 A" Add new cd "" on "F" find CD "" off "C" count the CDs and tracks in the catalog "" off "2> _1.txt x = $? If [$ X! = 0]; then Rm-F _1.txt Exit 1 else menu_choice = $ (cat _1.txt) Fi fi rm-F _1.txt} insert_title () {echo $ * >>$ title_file return} insert_track () {echo $ * >>$ tracks_file return} add_record_tracks () {cdtrack = 1 cdttitle = "" x = 0 while [$ x = 0] Do gdialog -- title "Enter track information for this CD" -- inputbox "track $ cdtrack, track title? "9 30 2> _1.txt x =$? TMP = $ (cat _1.txt) cdttitle =$ {TMP %, *} if ["$ tmp "! = "$ Cdttitle"]; then gdialog -- msgbox "sorry, no commas allowed" 9 18 continue Fi if [-n "$ cdttitle"]; then insert_track $ cdcatnum, $ cdtrack, $ cdttitle else cdtrack = $ (cdtrack-1) Fi cdtrack = $ (cdtrack + 1) done Rm-F _1.txt} add_records () {# prompt for the initial information gdialog -- title "" -- inputbox "Enter catalog name" 9 30 2> _1.txt x =$? If [$ x = 1]; then return fi TMP = $ (cat _1.txt) cdcatnum =$ {TMP %, *} Rm-F _1.txt gdialog -- title "" -- inputbox "Enter title" 9 30 2> _1.txt x =$? If [$ x = 1]; then return fi TMP = $ (cat _1.txt) cdtitle =$ {TMP %, *} Rm-F _1.txt gdialog -- title "" -- inputbox "Enter type" 9 30 2> _1.txt x =$? If [$ x = 1]; then return fi TMP = $ (cat _1.txt) cdtype =$ {TMP %, *} Rm-F _1.txt gdialog -- title "" -- inputbox "Enter artist/Composer" 9 30 2> _1.txt x =$? If [$ x = 1]; then return fi TMP = $ (cat _1.txt) cdac =$ {TMP %, *} Rm-F _1.txt # Check that they want to enter the information # If confirmed then append it to the titles file gdialog -- title "" -- yesno "about to add new entry $ cdcatnum $ cdtitle $ cdtype $ cdac "9 18 x = $? If [$ x = 0]; then insert_title $ cdcatnum, $ cdtitle, $ cdtype, $ cdac add_record_tracks fi return} find_cd () {cdcatnum = "" gdialog -- title "" -- inputbox "enter a string to search for in the CD titles" 9 30 2> _1.txt searchstr = $ (cat _1.txt) rm-F _1.txt if ["$ searchstr" = ""]; then return 0 fi grep "$ searchstr" $ title_file> $ temp_file set $ (WC-L $ temp_file) linesfound = $1 case "$ linesfound" in 0) GET _ Return "Sorry, nothing found" Return 0; 1); *) get_return "sorry, not unique. found the following "cat $ temp_file> _1.txt gdiwing -- title" -- textbox _1.txt 9 30 Rm-F _1.txt return 0 esac ifs = ", "Read cdcatnum cdtitle cdtype cdac <$ temp_file ifs =" "If [-z" $ cdcatnum "]; then get_return" sorry, cocould not extract catalog field from $ temp_file "Return 0 fi echo" Catalog Number: $ cdcatnum "'\ N '" Title: $ cdtitle "'\ N'" Echo type: $ cdtype "' \ N'" artist/Composer: $ cdac "> _1.txt gdialog -- title" "-- textbox _1.txt 9 30 Rm-F _1.txt gdialog -- yesno" view tracks for this CD? "9 18 x = $? If [$ x = 0]; then list_tracks fi return 1} update_cd () {if [-z "$ cdcatnum"]; then gdialog -- msgbox "You must select a CD first" 9 18 find_cd Fi if [-n "$ cdcatnum"]; then gdialog -- title "" -- yesno "This will re-enter the tracks for $ cdtitle" 9 18 if ["$? "= 0]; then grep-V" ^ $ cdcatnum, "$ tracks_file> $ temp_file MV $ temp_file $ tracks_file add_record_tracks fi return} count_cds () {set $ (WC-L $ title_file) num_titles = $1 set $ (WC-L $ tracks_file) num_tracks = $1 gdialog -- infobox "found $ num_titles CDs, with a total of $ num_tracks tracks "9 18 return} remove_records () {if [-z" $ cdcatnum "]; then get_return" You must select a CD first "find_cd Fi if [-N "$ cdcatnum"]; then gdialog -- title "" -- yesno "you are about to delete $ cdtitle" 9 18 if ["$? "= 0]; then grep-V" ^ $ cdcatnum, "$ title_file> $ temp_file MV $ temp_file $ title_file grep-V" ^ $ cdcatnum, "$ tracks_file> $ temp_file MV $ temp_file $ tracks_file cdcatnum =" "get_return" entry removed "fi return} list_tracks () {if [" $ cdcatnum "="]; then get_return "no CD selected yet" Return else grep "^ $ {cdcatnum}," $ tracks_file> $ temp_file num_tracks = $ (WC-L $ temp_file) if ["$ num_tracks" =" "]; Then get_return" no tracks found for $ cdtitle "else {cut-F 2--D, $ temp_file> _1.txt gdialog -- title" $ cdtitle: -"-- textbox _1.txt 9 30} fi return} if [! -F $ title_file]; then touch $ title_filefiif [! -F $ tracks_file]; then touch $ tracks_filefi # Now the application properx1 = 0 while [$ X1 = 0]; do set_menu_choice X1 =$? Case "$ menu_choice" in a) add_records; R) remove_records; f) find_cd; U) update_cd; c) count_cds; B) gdialog -- textbox title_file 9 30; esacdone # tidy up and leaverm-F temp_fileget_return "finished" Exit 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.