I am new to shell scripting and I have to to the following
I have a flat file with storename(lenth 20) , emailaddress(lenth 40), location(15). There is NO delimiters in that file.
Like the following str00001.txt
StoreName emailaddress location
xxxxxxx iiiiiiiiii@yahoo.com mmmmm
yyyyyyyyyyy acb@gmail.com lllllllllllllllllllllllll
zzz zzz@email.com ujeuri
I have to read line by line in the flat file get the email address and location and then make a call my java servlet by passing in the URL
- Read line by line
- Set email address and location in a variable
String email = "acb@gmail.com�;
String loc = �lllllllllllllllllllllllll�;
- set it my url like this (i know how to call the servlet through shell scripting)
http://localhost:8080/emailer/sslPages/sendemailservlet?emailAddress= email% location= loc
4. process next line from the flat file (loop until end of the file)
5. end of the loop I have to delete str00001.txt file
Hi Gurus,
Thanks in advance...
I am new to writing shell scripting and help me out reading a flat file with fixed length.
I have a fixed length flat file with storename(lenth 6) , emailaddress(lenth 15), location(10). There is NO delimiters in that file.
Like the following str00001.txt
StoreName emailaddress location
xxxxxxiiiiiiiiii@yahoo.com mmmmm
yyyyy aewwcb@gmail.com lllllllllllllllllllllllll
I have to read line by line in the flat file get the email address and location.and set it in a string
- Read line by line
- Set email address and location in a variable
String email = "iiiiiiiiii@yahoo.com�;
String loc = � mmmmm�;
- if (email == null)
throught error
else loc == null
thorugh error
- end of the loop I have to delete str00001.txt file
kshji
3
Just yesterday was this example.
---------- Post updated at 08:44 AM ---------- Previous update was at 08:42 AM ----------
Add this test after you parsed the fields.
if [ "$email" = "" ] ; then
echo "no email" >&2
else
loc=""
fi
Use the dd command to add carriage control information to the file. Write the output of the dd command to a new temp file or you can read from stdout
dd if=inputfile cbs=75 conv=unblock |
while read junk email location
do
# your code here
done