[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Gawk: Trap/handle a fatal error on tcp/ip networking
From: |
Haris Makripodis |
Subject: |
Gawk: Trap/handle a fatal error on tcp/ip networking |
Date: |
Sat, 29 Dec 2007 14:56:48 +0200 |
Hello to all,
I am trying to make a simple gawk program that tests and purses html
pages using gawk's built-in network support.
Code:
#!/usr/local/bin/gawk -f
BEGIN {
RS = ORS = "\r\n"
site = "www.wrong-url-for-test.com"
port = 80
uri = ""
service = "/inet/tcp/0/"site"/"port
print "GET " uri |& service
while ((service |& getline) > 0) print $0
close (service)
# command 1
# command 2
# command 3.....
}
My problem is that I 'm trying to find a way of trapping fatal errors in
case that the target ip is not valid. For example if I run the above
code, it returns
gawk: ./gawktest.awk:8: fatal: can't open two way socket
`/inet/tcp/0/www.wrong-url-for-test.com/80' for input/output (No such
file or directory)
My aim is to prevent this fatal error and handle it accordingly so as to
continue processing to the other parts of the programm (#command
1,2,3... on my example) .
The only solution I found so far is described on the below url:
http://groups.google.com/group/comp.lang.awk/browse_thread/thread/199ec020622eb691/27265a32f1be8475?
Is there another way of handling this error?
I wonder why tcp/ip connectivity issues should be FATAL in a first
place..
Thank you for your time,
Best regards
Haris
- Gawk: Trap/handle a fatal error on tcp/ip networking,
Haris Makripodis <=