Файловый менеджер - Редактировать - /var/www/html/gawk.zip
Ðазад
PK ! ���- - examples/misc/sample.csvnu �[��� p,"q,r",s p,"q""r",s p,"q,""r",s p,"",s p,,s PK ! �V�P� � examples/misc/findpat.awknu �[��� { if ($1 == "FIND") regex = $2 else { where = match($0, regex) if (where != 0) print "Match of", regex, "found at", where, "in", $0 } } PK ! to&u u examples/misc/arraymax.awknu �[��� { if ($1 > max) max = $1 arr[$1] = $0 } END { for (x = 1; x <= max; x++) print arr[x] } PK ! ��1� examples/misc/test-csv.awknu �[��� BEGIN { fp[0] = "([^,]+)|(\"[^\"]+\")" fp[1] = "([^,]*)|(\"[^\"]+\")" fp[2] = "([^,]*)|(\"([^\"]|\"\")+\")" FPAT = fp[fpat+0] } { print "<" $0 ">" printf("NF = %s ", NF) for (i = 1; i <= NF; i++) { printf("<%s>", $i) } print "" } PK ! C��� � examples/misc/simple-csv.awknu �[��� BEGIN { FPAT = "([^,]+)|(\"[^\"]+\")" } { print "NF = ", NF for (i = 1; i <= NF; i++) { printf("$%d = <%s>\n", i, $i) } } PK ! G���H H examples/misc/addresses.csvnu �[��� Robbins,Arnold,"1234 A Pretty Street, NE",MyTown,MyState,12345-6789,USA PK ! i8� examples/misc/arraymax.datanu �[��� 5 I am the Five man 2 Who are you? The new number two! 4 . . . And four on the floor 1 Who is number one? 3 I three you. PK ! �h�� � examples/misc/findpat.datanu �[��� FIND ru+n My program runs but not very quickly FIND Melvin JF+KM This line is property of Reality Engineering Co. Melvin was here. PK ! ��Ò? ? examples/network/panic.awknu �[��� BEGIN { RS = ORS = "\r\n" if (MyPort == 0) MyPort = 8080 HttpService = "/inet/tcp/" MyPort "/0/0" Hello = "<HTML><HEAD><TITLE>Out Of Service</TITLE>" \ "</HEAD><BODY><H1>" \ "This site is temporarily out of service." \ "</H1></BODY></HTML>" Len = length(Hello) + length(ORS) while ("awk" != "complex") { print "HTTP/1.0 200 OK" |& HttpService print "Content-Length: " Len ORS |& HttpService print Hello |& HttpService while ((HttpService |& getline) > 0) continue; close(HttpService) } } PK ! �l��� � examples/network/webgrab.awknu �[��� BEGIN { RS = "https?://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" } RT != "" { command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \ " > doc" NR ".html") print command } PK ! ^�1� � examples/network/stoxdata.txtnu �[��� Date,Open,High,Low,Close,Volume 9-Oct-00,22.75,22.75,21.375,22.375,7888500 6-Oct-00,23.8125,24.9375,21.5625,22,10701100 5-Oct-00,24.4375,24.625,23.125,23.50,5810300 PK ! � �N N examples/network/testserv.awknu �[��� BEGIN { CGI_setup("GET", "http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \ "&percent=a %25 sign", "1.0") for (i in MENU) printf "MENU[\"%s\"] = %s\n", i, MENU[i] for (i in PARAM) printf "PARAM[\"%s\"] = %s\n", i, PARAM[i] for (i in GETARG) printf "GETARG[\"%s\"] = %s\n", i, GETARG[i] } PK ! ~�$�� � examples/network/hello-serv.awknu �[��� BEGIN { RS = ORS = "\r\n" HttpService = "/inet/tcp/8080/0/0" Hello = "<HTML><HEAD>" \ "<TITLE>A Famous Greeting</TITLE></HEAD>" \ "<BODY><H1>Hello, world</H1></BODY></HTML>" Len = length(Hello) + length(ORS) print "HTTP/1.0 200 OK" |& HttpService print "Content-Length: " Len ORS |& HttpService print Hello |& HttpService while ((HttpService |& getline) > 0) continue; close(HttpService) } PK ! �9#�� � examples/network/protbase.awknu �[��� { request = request "\n" $0 } END { BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80" printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |& BLASTService printf "Content-Length: " length(request) "\n\n" |& BLASTService printf request |& BLASTService while ((BLASTService |& getline) > 0) print $0 close(BLASTService) } PK ! ���� � ! examples/network/protbase.requestnu �[��� PROGRAM blastn DATALIB month EXPECT 0.75 BEGIN >GAWK310 the gawking gene GNU AWK tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat caccaccatggacagcaaa PK ! FG� examples/network/PostAgent.shnu �[��� #!/bin/sh MobAg=/tmp/MobileAgent.$$ # direct script to mobile agent file cat > $MobAg # execute agent concurrently gawk -f $MobAg $MobAg > /dev/null & # HTTP header, terminator and body gawk 'BEGIN { print "\r\nAgent started" }' rm $MobAg # delete script file of agent PK ! w�5�_ _ examples/network/maze.awknu �[��� function SetUpServer() { TopHeader = "<HTML><title>Walk through a maze</title>" TopDoc = "\ <h2>Please choose one of the following actions:</h2>\ <UL>\ <LI><A HREF=" MyPrefix "/AboutServer>About this server</A>\ <LI><A HREF=" MyPrefix "/VRMLtest>Watch a simple VRML scene</A>\ </UL>" TopFooter = "</HTML>" srand() } function HandleGET() { if (MENU[2] == "AboutServer") { Document = "If your browser has a VRML 2 plugin,\ this server shows you a simple VRML scene." } else if (MENU[2] == "VRMLtest") { XSIZE = YSIZE = 11 # initially, everything is wall for (y = 0; y < YSIZE; y++) for (x = 0; x < XSIZE; x++) Maze[x, y] = "#" delete Maze[0, 1] # entry is not wall delete Maze[XSIZE-1, YSIZE-2] # exit is not wall MakeMaze(1, 1) Document = "\ #VRML V2.0 utf8\n\ Group {\n\ children [\n\ PointLight {\n\ ambientIntensity 0.2\n\ color 0.7 0.7 0.7\n\ location 0.0 8.0 10.0\n\ }\n\ DEF B1 Background {\n\ skyColor [0 0 0, 1.0 1.0 1.0 ]\n\ skyAngle 1.6\n\ groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\ groundAngle [ 1.2 1.57 ]\n\ }\n\ DEF Wall Shape {\n\ geometry Box {size 1 1 1}\n\ appearance Appearance { material Material { diffuseColor 0 0 1 } }\n\ }\n\ DEF Entry Viewpoint {\n\ position 0.5 1.0 5.0\n\ orientation 0.0 0.0 -1.0 0.52\n\ }\n" for (i in Maze) { split(i, t, SUBSEP) Document = Document " Transform { translation " Document = Document t[1] " 0 -" t[2] " children USE Wall }\n" } Document = Document " ] # end of group for world\n}" Reason = "OK" ORS "Content-type: model/vrml" Header = Footer = "" } } function MakeMaze(x, y) { delete Maze[x, y] # here we are, we have no wall here p = 0 # count unvisited fields in all directions if (x-2 SUBSEP y in Maze) d[p++] = "-x" if (x SUBSEP y-2 in Maze) d[p++] = "-y" if (x+2 SUBSEP y in Maze) d[p++] = "+x" if (x SUBSEP y+2 in Maze) d[p++] = "+y" if (p>0) { # if there are unvisited fields, go there p = int(p*rand()) # choose one unvisited field at random if (d[p] == "-x") { delete Maze[x - 1, y]; MakeMaze(x - 2, y) } else if (d[p] == "-y") { delete Maze[x, y - 1]; MakeMaze(x, y - 2) } else if (d[p] == "+x") { delete Maze[x + 1, y]; MakeMaze(x + 2, y) } else if (d[p] == "+y") { delete Maze[x, y + 1]; MakeMaze(x, y + 2) } # we are back from recursion MakeMaze(x, y); # try again while there are unvisited fields } } PK ! _9J� � examples/network/remconf.awknu �[��� function SetUpServer() { TopHeader = "<HTML><title>Remote Configuration</title>" TopDoc = "<BODY>\ <h2>Please choose one of the following actions:</h2>\ <UL>\ <LI><A HREF=" MyPrefix "/AboutServer>About this server</A></LI>\ <LI><A HREF=" MyPrefix "/ReadConfig>Read Configuration</A></LI>\ <LI><A HREF=" MyPrefix "/CheckConfig>Check Configuration</A></LI>\ <LI><A HREF=" MyPrefix "/ChangeConfig>Change Configuration</A></LI>\ <LI><A HREF=" MyPrefix "/SaveConfig>Save Configuration</A></LI>\ </UL>" TopFooter = "</BODY></HTML>" if (ConfigFile == "") ConfigFile = "config.asc" } function HandleGET() { if (MENU[2] == "AboutServer") { Document = "This is a GUI for remote configuration of an\ embedded system. It is is implemented as one GAWK script." } else if (MENU[2] == "ReadConfig") { RS = "\n" while ((getline < ConfigFile) > 0) config[$1] = $2; close(ConfigFile) RS = "\r\n" Document = "Configuration has been read." } else if (MENU[2] == "CheckConfig") { Document = "<TABLE BORDER=1 CELLPADDING=5>" for (i in config) Document = Document "<TR><TD>" i "</TD>" \ "<TD>" config[i] "</TD></TR>" Document = Document "</TABLE>" } else if (MENU[2] == "ChangeConfig") { if ("Param" in GETARG) { # any parameter to set? if (GETARG["Param"] in config) { # is parameter valid? config[GETARG["Param"]] = GETARG["Value"] Document = (GETARG["Param"] " = " GETARG["Value"] ".") } else { Document = "Parameter <b>" GETARG["Param"] "</b> is invalid." } } else { Document = "<FORM method=GET><h4>Change one parameter</h4>\ <TABLE BORDER CELLPADDING=5>\ <TR><TD>Parameter</TD><TD>Value</TD></TR>\ <TR><TD><input type=text name=Param value=\"\" size=20></TD>\ <TD><input type=text name=Value value=\"\" size=40></TD>\ </TR></TABLE><input type=submit value=\"Set\"></FORM>" } } else if (MENU[2] == "SaveConfig") { for (i in config) printf("%s %s\n", i, config[i]) > ConfigFile close(ConfigFile) Document = "Configuration has been saved." } } PK ! v�>� examples/network/stoxpred.awknu �[��� BEGIN { Init() ReadQuotes() CleanUp() Prediction() Report() SendMail() } function Init() { if (ARGC != 1) { print "STOXPRED - daily stock share prediction" print "IN:\n no parameters, nothing on stdin" print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80" print "OUT:\n commented predictions as email" print "JK 09.10.2000" exit } # Remember ticker symbols from Dow Jones Industrial Index StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \ SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \ MRK XOM EK IP", name); # Remember the current date as the end of the time series day = strftime("%d") month = strftime("%m") year = strftime("%Y") if (Proxy == "") Proxy = "chart.yahoo.com" if (ProxyPort == 0) ProxyPort = 80 YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort } function ReadQuotes() { # Retrieve historical data for each ticker symbol FS = "," for (stock = 1; stock <= StockCount; stock++) { URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \ "&a=" month "&b=" day "&c=" year-1 \ "&d=" month "&e=" day "&f=" year \ "g=d&q=q&y=0&z=" name[stock] "&x=.csv" printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData while ((YahooData |& getline) > 0) { if (NF == 6 && $1 ~ /Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) { if (stock == 1) days[++daycount] = $1; quote[$1, stock] = $5 } } close(YahooData) } FS = " " } function CleanUp() { # clean up time series; eliminate incomplete data sets for (d = 1; d <= daycount; d++) { for (stock = 1; stock <= StockCount; stock++) if (! ((days[d], stock) in quote)) stock = StockCount + 10 if (stock > StockCount + 1) continue datacount++ for (stock = 1; stock <= StockCount; stock++) data[datacount, stock] = int(0.5 + quote[days[d], stock]) } delete quote delete days } function Prediction() { # Predict each ticker symbol by prolonging yesterday's trend for (stock = 1; stock <= StockCount; stock++) { if (data[1, stock] > data[2, stock]) { predict[stock] = "up" } else if (data[1, stock] < data[2, stock]) { predict[stock] = "down" } else { predict[stock] = "neutral" } if ((data[1, stock] > data[2, stock]) && (data[2, stock] > data[3, stock])) hot[stock] = 1 if ((data[1, stock] < data[2, stock]) && (data[2, stock] < data[3, stock])) avoid[stock] = 1 } # Do a plausibility check: how many predictions proved correct? for (s = 1; s <= StockCount; s++) { for (d = 1; d <= datacount-2; d++) { if (data[d+1, s] > data[d+2, s]) { UpCount++ } else if (data[d+1, s] < data[d+2, s]) { DownCount++ } else { NeutralCount++ } if (((data[d, s] > data[d+1, s]) && (data[d+1, s] > data[d+2, s])) || ((data[d, s] < data[d+1, s]) && (data[d+1, s] < data[d+2, s])) || ((data[d, s] == data[d+1, s]) && (data[d+1, s] == data[d+2, s]))) CorrectCount++ } } } function Report() { # Generate report report = "\nThis is your daily " report = report "stock market report for "strftime("%A, %B %d, %Y")".\n" report = report "Here are the predictions for today:\n\n" for (stock = 1; stock <= StockCount; stock++) report = report "\t" name[stock] "\t" predict[stock] "\n" for (stock in hot) { if (HotCount++ == 0) report = report "\nThe most promising shares for today are these:\n\n" report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" } for (stock in avoid) { if (AvoidCount++ == 0) report = report "\nThe stock shares to avoid today are these:\n\n" report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" } report = report "\nThis sums up to " HotCount+0 " winners and " AvoidCount+0 report = report " losers. When using this kind\nof prediction scheme for" report = report " the 12 months which lie behind us,\nwe get " UpCount report = report " 'ups' and " DownCount " 'downs' and " NeutralCount report = report " 'neutrals'. Of all\nthese " UpCount+DownCount+NeutralCount report = report " predictions " CorrectCount " proved correct next day.\n" report = report "A success rate of "\ int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n" report = report "Random choice would have produced a 33% success rate.\n" report = report "Disclaimer: Like every other prediction of the stock\n" report = report "market, this report is, of course, complete nonsense.\n" report = report "If you are stupid enough to believe these predictions\n" report = report "you should visit a doctor who can treat your ailment." } function SendMail() { # send report to customers customer["uncle.scrooge@ducktown.gov"] = "Uncle Scrooge" customer["more@utopia.org" ] = "Sir Thomas More" customer["spinoza@denhaag.nl" ] = "Baruch de Spinoza" customer["marx@highgate.uk" ] = "Karl Marx" customer["keynes@the.long.run" ] = "John Maynard Keynes" customer["bierce@devil.hell.org" ] = "Ambrose Bierce" customer["laplace@paris.fr" ] = "Pierre Simon de Laplace" for (c in customer) { MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c print "Good morning " customer[c] "," | MailPipe print report "\n.\n" | MailPipe close(MailPipe) } } PK ! �����'