File: extract1.sh

package info (click to toggle)
html-xml-utils 6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,620 kB
  • sloc: ansic: 10,027; sh: 2,135; lex: 189; yacc: 125; perl: 123; makefile: 122
file content (35 lines) | stat: -rwxr-xr-x 564 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash

# This test can only run if netcat is present
#
if ! type nc >/dev/null; then exit; fi

PORT=54325			# Some port that is unlikely to be in use

# Start 11 "servers" that redirect to each other
#
for ((i = 0; i < 11; i++)); do
  ((p = PORT + i))
  ((q = p + 1))
  echo -e "HTTP/1.1 302\r\nLocation: http://localhost:$q/\r\n\r" |\
    nc -l $p >/dev/null &
done

./hxextract body http://localhost:$PORT/ 2>&1 | grep -q 'Too many links'

code=$?

kill %1
kill %2
kill %3
kill %4
kill %5
kill %6
kill %7
kill %8
kill %9
kill %10
kill %11
wait

exit $code