HTo - HTTP POST with BASH
Posted 08-01-2008 at 01:22 PM by Marcelo_Vergara
#!/bin/bash
if [ -z $1 ] || [ -z "$2" ]; then
echo "Uso: $0 phone \"string\""
exit 1
fi
TEL=$1
MSG=$2
HOST="172.26.1.75"
URL="/pluggingForward/sendMessage.jsp"
PORT="80"
PROF="hehehehehe"
PWD="hahahaha"
ANUM="927"
TAM=`echo "<REQUEST PROF=\"war_sms_mt\">
<PWD>hahahaha</PWD>
<APP_TAG></APP_TAG>
<ANUM>927</ANUM>
<BNUM>$TEL</BNUM>
<PLOAD>
<SMS>$MSG</SMS>
</PLOAD>
</REQUEST>" | wc -c`
echo "POST $URL HTTP/1.1
Host: $HOST
Content-Length: $TAM
Content-Type: text/wml
<REQUEST PROF=\"war_sms_mt\">
<PWD>hahahaha</PWD>
<APP_TAG></APP_TAG>
<ANUM>927</ANUM>
<BNUM>$TEL</BNUM>
<PLOAD>
<SMS>$MSG</SMS>
</PLOAD>
</REQUEST>" | /usr/bin/nc -w 10 $HOST $PORT >> /dev/null
if [ $? -eq "0" ]; then
exit 0
else
exit 1
fi
if [ -z $1 ] || [ -z "$2" ]; then
echo "Uso: $0 phone \"string\""
exit 1
fi
TEL=$1
MSG=$2
HOST="172.26.1.75"
URL="/pluggingForward/sendMessage.jsp"
PORT="80"
PROF="hehehehehe"
PWD="hahahaha"
ANUM="927"
TAM=`echo "<REQUEST PROF=\"war_sms_mt\">
<PWD>hahahaha</PWD>
<APP_TAG></APP_TAG>
<ANUM>927</ANUM>
<BNUM>$TEL</BNUM>
<PLOAD>
<SMS>$MSG</SMS>
</PLOAD>
</REQUEST>" | wc -c`
echo "POST $URL HTTP/1.1
Host: $HOST
Content-Length: $TAM
Content-Type: text/wml
<REQUEST PROF=\"war_sms_mt\">
<PWD>hahahaha</PWD>
<APP_TAG></APP_TAG>
<ANUM>927</ANUM>
<BNUM>$TEL</BNUM>
<PLOAD>
<SMS>$MSG</SMS>
</PLOAD>
</REQUEST>" | /usr/bin/nc -w 10 $HOST $PORT >> /dev/null
if [ $? -eq "0" ]; then
exit 0
else
exit 1
fi



