User:Scsbot/formtools/formsubmit

From Wiktionary, the free dictionary
Jump to navigation Jump to search
tag=$1
baseurl=$2
cookiefile=$3

baseurl2=`expr "$baseurl" : '\([^/]*//[^/]*\).*'`

tf3=tf$$.3

rm="/bin/rm -f"

submurl=`cat \`formgettmpfile $tag .action\``	# XXX
submmethod=`cat \`formgettmpfile $tag .method\``	# XXX

if test $submmethod != "post"
then
	echo "unexpected (form method $submmethod)" >&2
	exit 1
fi

if expr "$submurl" : '^/' > /dev/null
then	:
else
	echo "unexpected (non-relative submission URL $submurl)" >&2
	exit 1
fi

# XXX:
submurl=`echo "$submurl" | sed 's/&/\&/g'`

sep=abcdefghijklmnopqrstuv

formmakesubm $tag $sep | sed 's/$/
/' > $tf3

httpget -cookies -cookiefile $cookiefile -post -type "multipart/form-data; boundary=$sep" "$baseurl2/$submurl" < $tf3

$rm $tf3

exit 0