Help with database deleting data!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with database deleting data!!!
# 1  
Old 05-26-2012
Help with database deleting data!!!

Hi, I'm new to programming in shell and I wanted to make a simple database on shell script but I'm having trouble in deleting data. I would apreciate any kind of help. Thank you in adavanced.

Last edited by Lina_14; 06-03-2012 at 08:25 PM..
# 2  
Old 05-27-2012
Hi Lina_14,

In read file1 and cat $file variables are different and program seems to hang because cat waits for input from keyboard. I had to remove it and the sixth option (6.Delete file) worked.
This User Gave Thanks to birei For This Post:
# 3  
Old 05-27-2012
Thank you for your replay

The problem is that when I record data, I want to delite not only the file but also the data from the database :/, I would apreciate any kind of help.
Code:
i="y"
echo "Enter name of database "
read db
while [ $i = "y" ]
do
clear
echo "1.Enter id "
echo "2.Display current dir"
echo "3.Listing the dir"
echo "4.Make a dir"
echo "5.Copy a file"
echo "6.Rename file"
echo "7.Delete file"
echo "8.Edit file"
echo "9.Shto regjistrim"
echo "10.Exit"
echo "Enter your choice"
read ch
case $ch in

1)echo "Enter id "
read id
grep -i "$id" $db;;
2)echo "Current Dir is : "
  pwd;;
  3)echo "Directories are"

    ls;;
    4)echo "Enter dir name to create"
     read d
             mkdir $d
                 echo $d" Dir is created";;
             5)echo "Enter filename from copy"
              read f1
               echo "Enter filenm2 to be copied"
                read f2
                    #cat $f1 > $f2
                        cp $f1 $f2
                            echo $f2" is copied from "$f1;;
                        6)echo "Enter file name to rename"
                         read f1
                          echo "Enter new name of file"
                           read f2
                                   mv $f1 $f2
                                       echo $f1" is renamed as "$f2;;
                                   7)echo "Enter any filenm to be delete"
                                    read f1
                                            rm $f1
                                                echo $f1" is deleted";;
                                            8)echo "Enter any file to be editing "
                                             read f1
                                                     vi $f1;;
9)echo "Enter the name"
read kdi
echo “$kdi” > dbkodi
cat dbkodi
echo "Enter the profesion:"
read tpi
echo ”$tpi” > dbtitulli
cat dbtitulli
echo "Enter the school "
read ept
echo “$ept” > dbemri_piktorit
cat dbemri_piktorit
echo "Enter the class"
read cmm
echo ”$cmm” >dbcmimi
cat dbcmimi
echo "$kdi $tpi $ept $cmm">>$db;;

                                                 10)echo "Have a nice time"
                                                 exit;;
                                                 *)echo "Invalid choice entered";;
                                                 esac
                                                 echo "Do u want to continue ? "
                                                 read i
                                                 if [ $i != "y" ]
                                                 then
                                                 exit
                                                 fi
                                                 done


Last edited by Scott; 05-27-2012 at 08:45 AM.. Reason: Use code tags, please and indent your code properly
# 4  
Old 05-28-2012
change these
Code:
.................................
.......................
read db
if [ -z "$db" ] ; then echo "DB name is empty!! " ; exit 1 ; fi
.................................
.......................
cp $f1 $f2
[ $? -eq 0 ] && echo "$f2 is copied from $f1";;
.................................
.......................
mv $f1 $f2
[ $? -eq 0 ] && echo "$f1 is renamed as $f2";;
.................................
.......................
rm $f1
[ $? -eq 0 ] && echo $f1" is successfully deleted";;
.................................
.......................

if [ $c != "y" ]
then
exit
fi
done

This User Gave Thanks to ygemici For This Post:
# 5  
Old 05-29-2012
It still doesnt delete the data from database!!!

Example when I put records on the database and then i want to delet a line based on ID given, in terminal its says "Data deleted" but in database still exist. Thank you for improving my code.
# 6  
Old 05-29-2012
try using this code where you are deleting files-
Code:
/bin/rm -f <dir_name/file_name> 2>> output.err 1>>output.log

and check the log files
# 7  
Old 05-29-2012
Quote:
Originally Posted by Lina_14
Example when I put records on the database and then i want to delet a line based on ID given, in terminal its says "Data deleted" but in database still exist. Thank you for improving my code.
a little correction about my writes
Code:
........
esac
         echo "Do u want to continue ? "
         read c
if [ $c != "y" ]
then
exit
fi
done

and i can not see the delete records(ID) from database in your code ? which (choice )one ? is it 7 ?
This User Gave Thanks to ygemici For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Need help on Insert data to mySQL database

Hi guys, I would like to seek help on inserting data whenever the switch is on or off to my sensor mySQL database in phpMyAdmin from my control.php. I'm using Raspberry PI as my hardware and follow a few tutorials to create my own Web Control Interface, it works perfectly without insert method.... (1 Reply)
Discussion started by: aoiregion
1 Replies

2. Shell Programming and Scripting

Deleting data

Need Assistance in a script to delete date for Below example There are four period(.) line . I wanted to delete 2 period(.) from below . 5 .TODAY...MOSTLY SUNNY. HIGHS 58 TO 63. LIGHT WINDS IN THE MORNING 6 BECOMING NORTH 10 TO 15 MPH IN THE AFTERNOON. 7 .TONIGHT...MOSTLY CLEAR.... (5 Replies)
Discussion started by: ajayram_arya
5 Replies

3. UNIX for Dummies Questions & Answers

Deleting the unwanted data based on condition

hi i have my input data like this aaa bbb ccc asa dff nmj mnj saa dff oik aax cdx saa oik asq sdf dssi want my output file to be like this mnj saa dff oik aax cdx saa oiki want to retain only those lines which will have oik just below them and i want oik to be as next column to those... (1 Reply)
Discussion started by: anurupa777
1 Replies

4. Shell Programming and Scripting

Mask the Oracle Database Data

Hi, We have to mask the data that is coming from production environment to Non-production environment. The database is running in oracle platform. If anybody has generic scripts to achive this task,it would be great if that can be shared with me? Thank you, Jayaprakash. (10 Replies)
Discussion started by: bandaru_0810
10 Replies

5. Shell Programming and Scripting

Script problem with deleting data

The 10.Delete data doesnt work at all, plesase anyone could help on that. When I choose options 10 to delete a record it only copy the selected data on the other file dbs1 but doesnt delete it from the database where other records are. #! /bin/bash i="y" echo "Enter name of database " read db... (6 Replies)
Discussion started by: Lina_14
6 Replies

6. Shell Programming and Scripting

Deleting shorter lines from data file

Hello, I have the following data file structure: 1234 text 2345 text 3456 text text text 4567 text text text 5678 text text text 6789 text text text I simply want to delete all of the lines that only have one text column (i.e. the first two lines in this case). The output would be:... (1 Reply)
Discussion started by: palex
1 Replies

7. Shell Programming and Scripting

extracting data and store in database

Hello all, I have this text file data. The data are separated by comma in three column and space or line feed to start a new row anderson helberg, Jane, brother Sister ,mother,grandpa bombay,new york, china I would like store them in the following format. field1 ... (2 Replies)
Discussion started by: mam
2 Replies

8. UNIX for Dummies Questions & Answers

Howto capture data from rs232port andpull data into oracle database-9i automatically

Hi, i willbe very much grateful to u if u help me out.. if i simply connect pbx machine to printer by serial port RS232 then we find this view: But i want to capture this data into database automatically when the pbx is running.The table in database will contain similar to this view inthe... (1 Reply)
Discussion started by: boss
1 Replies

9. Shell Programming and Scripting

Moving data from one database to other

Dear All, I have 2 databases, There is a lot of data in both the databases, i would like to move some data from one database to the other. I would like to accept 2 parameters from the user, i.e. emplyee id & dept, on entering the 2 i will unload all the data from the tables to the flat files.... (6 Replies)
Discussion started by: lloydnwo
6 Replies
Login or Register to Ask a Question