aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2015-02-12 23:11:37 +0100
committerPetter Reinholdtsen <pere@hungry.com>2015-02-12 23:11:37 +0100
commitd704547822712346f0d15ffb7d8c7bf770083318 (patch)
treeb46f442bf5da44aef043fd9208c1edc41bbd2203
parent4010c1ece08cd3297830fdf8cd7dcb8eb57ca559 (diff)
Make more robust and configurable.
-rwxr-xr-xruncheck25
1 files changed, 21 insertions, 4 deletions
diff --git a/runcheck b/runcheck
index b9f54fc..1abe33a 100755
--- a/runcheck
+++ b/runcheck
@@ -1,7 +1,24 @@
#!/bin/sh
-cat testurls.txt | while read url ; do
- filename=$(echo "$url" | cut -d/ -f3-| sed 's%/$%%' |tr / %)
- echo "$url"
- phantomjs netsniff.js "$url" > "har-data/$filename.har"
+set -e
+
+file=testurls.txt
+
+if [ "$1" ] ; then
+ file="$1"
+fi
+
+cat $file | while read url ; do
+ case "$url" in
+ http*)
+ # Save with URL as filename, replacing / with % and dropping trailing slash.
+ filename=$(echo "$url" | sed 's%/$%%' |tr / %)
+ echo "$url"
+ if phantomjs netsniff.js "$url" > "har-data/$filename.har.new" ; then
+ mv "har-data/$filename.har.new" "har-data/$filename.har"
+ else
+ rm "har-data/$filename.har.new"
+ fi
+ ;;
+ esac
done