fix parse_to_csv
This commit is contained in:
parent
dc640bc658
commit
9041f7dcbc
|
@ -100,7 +100,21 @@ done
|
|||
parse_to_csv() {
|
||||
local input="$1"
|
||||
local output="$2"
|
||||
: > "$output"
|
||||
local output_dir=$(dirname "$output")
|
||||
|
||||
# Ensure the output directory exists
|
||||
if [[ ! -d "$output_dir" ]]; then
|
||||
mkdir -p "$output_dir" || { echo "Failed to create directory $output_dir"; exit 1; }
|
||||
fi
|
||||
|
||||
# Check if input file exists
|
||||
if [[ ! -f "$input" ]]; then
|
||||
echo "Input file $input does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
: > "$output" # Clear output file before appending
|
||||
|
||||
grep -Eo 'https?://[^ ]+' "$input" | sort -u | while read -r url; do
|
||||
local ttfb_line=$(grep -m 1 "$url" "$input" | grep 'TTFB test passed' | awk -F'Mean TTFB: ' '{print $2}')
|
||||
local ab_line=$(grep -m 1 "$url" "$input" | grep 'ApacheBench test passed' | awk -F'Average time: ' '{print $2}')
|
||||
|
@ -114,6 +128,7 @@ parse_to_csv() {
|
|||
done
|
||||
}
|
||||
|
||||
|
||||
parse_to_csv "/logs/scan.log" "/logs/scan.csv"
|
||||
|
||||
upload_to_hastebin() {
|
||||
|
|
Loading…
Reference in New Issue