Search the web
Sign In
New User? Sign Up
geeksthatgawk · for GNU Awk questions & discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
can we call awkscript from a webbrowser   Message List  
Reply | Forward Message #210 of 221 |
RE: [Geeks that Gawk] can we call awkscript from a webbrowser

Srinivas,

Here is an awk script I wrote some time ago for adding commas (every 3
digits) into a number. Command line format would be something like:
echo 1234567 | awk -f comma.awk

Where "comma.awk" would be the filename of the below script.



=======



#

# awk program to add commas in a number every 3 digits

#

{

# ... save off the number

num = $1 ;

# ... get length of the number entered

lng = length($1) ;



# ... determine the number of commas that needs to be added to the
number entered

commas = int(lng/3) ;



# ... determine number of remaining numbers (modulo arithmetic)

lose1 = lng % 3 ;



# ... no remaining numbers AND number needs at least ONE comma then

# ... subtract one from comma count before we start

if (( ! lose1 ) && ( commas > 0 ))

{

commas -= 1 ;

}



# ... initialize the string variable to an empty string

num = "" ;



for( x = 1 ; x <= commas ; x++ )

{

# ... add 3 to a loop counter

y += 3



# ... starting at the end of the number, strip off 3 chars at a time

get = substr($1,lng-y+1,3) ;



if ( x == 1 )

{

num = get ;

}

else

{

# ... add a comma to the string

num = get "," num ;

}

}



# ... if have less than another set of 3 numbers, then

# ... add what's left of the number to the front

rest = lng - (commas * 3 )



if ( rest > 0 )

{

# ... if number was shorter than 3 chars then print it without comma

if(lng>3)

{

get = substr($1,1,rest) ;

num = get "," num ;

}

else

{

num = substr($1,1,rest) ;

}

}

print num ;

}



Sorry, but can't help with the rest of your request, beyond my skill
set right now.



Good luck,

dan



________________________________

From: geeksthatgawk@yahoogroups.com
[mailto:geeksthatgawk@yahoogroups.com] On Behalf Of schpanich
Sent: Thursday, September 07, 2006 12:14 AM
To: geeksthatgawk@yahoogroups.com
Subject: [Geeks that Gawk] can we call awkscript from a webbrowser



Hello friends,
My name is Srinivas Chakrpani, I have so many doubts in awk scripting.
The scripting tools like perl,php,python can call from a web browser.
Just by modification the Add-Handler types in httpd.conf file (for
apache web server). Is it possible in the same way we can call any
awkscript from the webserver. If so please give the details what we
have to do to the file/ permissions to files and with a example script.

Moreover I want to format the numbers in awk that is
123456 as 1,23,456 how is it possible if possible please share me with
a example

I want access multiple files in awk is it possible?

Any scripts in awk are please send to my mail address giving below

chs.chakrapani@... <mailto:chs.chakrapani%40licindia.com>




This email may contain confidential and privileged material for the sole use of
the intended recipient(s) and only for those purposes previously or herein
authorized by the sender. Any review, use, distribution or disclosure by others,
or use by the recipient for unauthorized purposes, is strictly prohibited. If
you are not the intended recipient (or authorized to receive for the recipient),
please contact the sender by reply email and delete all copies of this message.

Disclaimer:
This email may contain confidential and privileged material for the sole use of
the intended recipient(s) and only for those purposes previously or herein
authorized by the sender. Any review, use, distribution or disclosure by others,
or use by the recipient for unauthorized purposes, is strictly prohibited. If
you are not the intended recipient (or authorized to receive for the recipient),
please contact the sender by reply email and delete all copies of this message.


[Non-text portions of this message have been removed]




Thu Sep 7, 2006 1:19 pm

dasthcc
Offline Offline
Send Email Send Email

Forward
Message #210 of 221 |
Expand Messages Author Sort by Date

Hello friends, My name is Srinivas Chakrpani, I have so many doubts in awk scripting. The scripting tools like perl,php,python can call from a web browser. ...
schpanich
Offline
Sep 7, 2006
11:52 am

Srinivas, Here is an awk script I wrote some time ago for adding commas (every 3 digits) into a number. Command line format would be something like: echo...
Stout, Danny
dasthcc
Offline Send Email
Sep 7, 2006
1:22 pm

... { while (1) { new = gensub(/(.*[0-9])([0-9]{3})/,"\\1,\\2",1) if ($0 == new) break $0 = new } print } echo hello 12123456 wewr | gawk --re-interval -f...
Daniel Ajoy
daniel_ajoy
Offline Send Email
Sep 7, 2006
9:18 pm

I don't understand what you mean. Ask the group. Daniel...
Daniel Ajoy
daniel_ajoy
Offline Send Email
Sep 8, 2006
1:44 pm

... the awk file has to be executable in httpd.conf : <IfModule mod_mime.c> ... AddHandler cgi-script awk ... </IfModule> The file index.awk starts with ...
Daniel Ajoy
daniel_ajoy
Offline Send Email
Sep 7, 2006
1:33 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help