Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

how to create config.bat file

Original Message
Name: qakalla
Date: November 17, 2006 at 17:11:11 Pacific
Subject: how to create config.bat file
OS: XP
CPU/Ram: 2.8
Model/Manufacturer: HP
Comment:
This is in Unix Shell Scripting. using Putty.exe
The application I'm working on is to add,remove and update the information of a person.I need help to create a file config.bat so it will automatically create the person's ID number.
I would like to start from 1000 then add 1 everytime I add a person. This is the code I have to add the person. I'm missing the ID number.

answer=y
while [ "$answer" = y ]
do
clear
echo -e "First Name: \b\c "
read first
clear
echo -e "Last Name: \b\c"
read last
clear
echo -e "M: \b\c "
read m
clear
echo -e "Street: \b\c"
read street
clear
echo -e "City: \b\c"
read city
clear
echo -e "State: \b\c"
read state
clear
echo -e "Zipcode: \b\c"
read zip
echo -e "Telephone: \b\c"
read phone
echo "$first:$last:$m:$street:$city:$state:$zip:$phone" >> store_data.txt
echo -e "Any more to add? (Y)es or (N)o> _\b\c"
read answer
case $answer in
[Yy]* ) answer=y ;;
* ) answer=n ;;
esac
done

...thanks.


Report Offensive Message For Removal


Response Number 1
Name: Devaraj (by Fidy)
Date: November 17, 2006 at 19:04:10 Pacific
Subject: how to create config.bat file
Reply: (edit)
when u run the program for the first time, add 1000 as ID and keep adding one each time it runs.. i haven't tested this piece of code but u can work around to it...

tail -2 store_data.txt| head -1 | awk -F :'{print $1}' | read return

expr $return + 0 >/dev/null 2>&1
if [ $? -ne 0 ]
then
id=1000
else
if [ $return -gt 0 -a $return -lt 9999999 ]
then
id=$return+1
fi

echo "$id:$first:$last:$m:$street:$city:$state:$zip:$phone" >> store_data.txt


Regards,
Devaraj Takhellambam


Report Offensive Follow Up For Removal

Response Number 2
Name: qakalla
Date: November 17, 2006 at 21:18:46 Pacific
Subject: how to create config.bat file
Reply: (edit)
Thanks a lot Fidy, I will try to run the code tom..

Report Offensive Follow Up For Removal

Response Number 3
Name: Devaraj (by Fidy)
Date: November 20, 2006 at 00:38:52 Pacific
Subject: how to create config.bat file
Reply: (edit)
inlcude this piece of code

tail -1 store_data.txt | awk -F: '{print $1}'| read return
expr $return + 0 >/dev/null 2>&1
if [ $? -ne 0 ]
then
id=1000
elif [ $return -gt 0 -a $return -lt 9999999 ]
then
id=`expr $return + 1`
fi
echo $id


Regards,
Devaraj Takhellambam


Report Offensive Follow Up For Removal

Response Number 4
Name: qakalla
Date: November 20, 2006 at 21:17:04 Pacific
Subject: how to create config.bat file
Reply: (edit)
Thanks for your help. On the same application i have to search the person with the id i entered.and display the info only by id.I will post the code on the search part, thanks again.

Report Offensive Follow Up For Removal

Response Number 5
Name: qakalla
Date: November 26, 2006 at 16:58:06 Pacific
Subject: how to create config.bat file
Reply: (edit)
I need some help please. I did try the code above but it didn't work. Can someone tell me what am i doing wrong. Thanks.

return=`tail -1 store_data.txt | awk -F : '{ print $1 }'`
if [ $return == "" ]
then
id=1000
else
if [ $return -gt 0 -a $return -lt 9999999 ]
then
id=`expr $return + 1`
fi
fi


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: how to create config.bat file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




acer 312T BIOS problem

K7 Turbo possible max fsb?

Pc anywher problem

WinFLP & OE/Outlook2003

Computer resets after a few minutes


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC