regarding bash script
Dear Experts,
I want to create user information after querying file called "STORE_FILE". In STORE_FILE i had the information of total email users with expiry date. Like: [root@mail home]vi STORE_FILE ###USERID:EXPIRYDATE xyz@abc.com.np:2011-01-10 mno@abc.com.np:2011-05-11 and so on.......... now i want to create a bash script by which it will show the expiry date of particular user. And also want script to add, edit, view and del unwanted userid from the file STORE_FILE. Please any help will be appreciated. Thank you!!! Regards, Manoj |
Are you looking for someone to do your homework?
|
commands
some commands to research...
use 'grep' tp search for something use 'sed' to delete lines (matching what you want) use 'echo' to insert something check out the man pages and come back if you have specific questions. No we will not create this for you. Show some initiative. |
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
|
here is what i have tried
Dear ALL,
I have tried like this: i have just started the code with bash and for now i am stucked in if else condition. for the 1st function1 i have asked user to input the user name and then with grep command i have search the input username and append to tmp file and then i count the line of tmp file. now temp file has two conditions, either 1 or 0 so with this i want to assign a values present on t file. whatever value present on t file will assign to value. Now i have used if condition for jumping 2 statement. but when i run the script it only jump to one condition, what ever value present on t file. Please suggest what to do?? I think i am going wrong way....but this is all what i know......sorry.... ********************************************************************* [root@mail bashtest]# ls database t test1 tmp ********************************************************************** [root@mail bashtest]vi test1 ###USERID:EXPIRYDATE xyz@abc.com.np:2011-01-10 mno@abc.com.np:2011-05-11 and so on......... ********************************************************************* #!/bin/bash function function1 { echo -e "Enter Username:\c " read user1 x=$user1 #echo $x grep $user1 ./database > tmp wc -l tmp | awk '{print $1}' > t value="$/home/manoj/bashtest/t" if [ $value -eq 1 ]; then echo "User $user1 already exist in database" else echo "not in database" # echo $user1':'>> "/home/manoj/bashtest/database" # echo -e "Enter Expire date:\c" # read date1 # echo $date1 >> "/home/manoj/bashtest/database" # } fi } echo "PLEASE ENTER:" echo "1. Add User In Expire file:" echo "2. Delet User From Expire file:" echo "3. Show User Expire:" echo "4. Edit User in Expire:" read case; case $case in 1) function1 #2) echo "2";; #3) echo "3";; #4) echo "4";; esac ********************************************************************** |
After value="$/home/manoj/bashtest/t", add
Code:
echo "DEBUG: \$value is '$value'" It's easier to read your code if you put it in code tags (that's a link to instructions or you may prefer to use "Advanced Edit" mode which has a # button for code tags). It's helpful if you also post the output from running the script. |
Quote:
I Get the following output after adding echo "DEBUG: \$value is '$value'" ********************************************************************* [root@propel bashtest]# sh test1 PLEASE ENTER: 1. Add User In Expire file: 2. Delet User From Expire file: 3. Show User Expire: 4. Edit User in Expire: 1 Enter Username:manoj DEBUG: $value is '$/home/manoj/bashtest/t' test1: line 13: [: $/home/manoj/bashtest/t: integer expression expected not in database [root@propel bashtest]# ******************************************************************** |
Exactly what catkin was hinting to you; look at that output and THINK about why you don't get what you expect.
The 'set -vx' stuff is good advice. I also recommend you bookmark & read these: http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
All times are GMT -5. The time now is 03:03 PM. |