Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get sequential response from a http server ...

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi !

I've been looking for threads that could solve my problem but I didn't find ... Maybe some of you could help me !

I want a script that could connect to a http server and modifying à part of the url in a sequential way ...
...
...

I supposed I have to use system("telnet 80") ... combined with the GET method ...
Thanx for your help !
SpBoy10 ;-)
 
I suggest postong to the "UNIX Scripting" forum.....

vlad
 
No need for that vlad ;)


function basever() {
"gawk -W -version" | getline base
return base
}

BEGIN {
#get version
if (a = basever()) {
m = split(a,arr,".")
if (m && arr[2] < 1 && arr[3] < 95) {
print &quot;Incompatible awk version for networking.&quot;
exit
}
} else {
print &quot;Problem determining awk version.
exit
}

#start action
RS = ORS = &quot;\r\n\r\n&quot;

if (!ARGV[1]) {
printf &quot;Need number of connects.&quot;
exit
} else {
#open connection
sock = &quot;/inet/tcp/0/ for (x=1 ; x <= ARGV[1] ; x++) {
#format request
url = sprintf(&quot;%s%s%s&quot;, &quot; x ,&quot;/index.htm&quot;)
#send to sock buffer
print &quot;GET&quot; &quot; &quot; url |& sock

#send/read from sock::bidirectional pipe

while ((sock |& getline) > 0) {
print $0
#alternately build a global array with all the different pages
#array[x,&quot;PAGE&quot;] = $0
#good for mirroring maybe....
}
printf &quot;Ending%2d&quot;, x
}
}
close(sock)
}

called like awk -f scriptname 10
Thanks go to J.Kahr for his work on this extension.
 
Nice one, marsd!

Wouldn't
called like awk -f scriptname 10
be

called like gawk -f scriptname 10

Do other 'awk-s' [tawk, mawk etc] have the networking capabilities? Just curious.........

vlad
 
I can't totally take the credit for this one: it is heavily adapted from Juergen Kahr's GETURL.

Yes, you are probably right, I run SuSE linux with the later awk versions and they just symlink awk and gawk to the same binary,so I got into that habit wherever I go..
Not good when people are using solaris and tru-64 and whatnot :(
Also the basever function needs help: if someone is running gawk 2.(? > 1).95+ (if there is such a thing) it fails.

Lastly:
I think it is just gawk > 3.0.95 that has this capability.

Bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top