x_lucifer
x_lucifer

Reputation: 11

Shell Script : why this script does not works

Im new to shell scripting. i want send curl request via tor using shell scipting for increase voting system actual command is

(torsocks curl https://www.polltab.com/api/poll/fhfjyQ4vRJ/vote' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.polltab.com/fhfjyQ4vRJ' -H 'Content-Type: application/json' -H 'Origin: https://www.polltab.com' -H 'Connection: keep-alive' -H 'Cookie: _ga=GA1.2.1092908151.1597994149; _gid=GA1.2.137579554.1598335057; _gat=1' --data-raw '{"choiceIds":["5f44a89da6ca932af2b92206"]}')

when i enter this command in my terminal its working perfectly but i try to automate this command it should not work correctly

#! /bin/bash

url="'https://www.polltab.com/api/poll/fhfjyQ4vRJ/vote' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0' -H 'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: https://www.polltab.com/fhfjyQ4vRJ' -H 'Content-Type: application/json' -H 'Origin: https://www.polltab.com' -H 'Connection: keep-alive' -H 'Cookie: _ga=GA1.2.1092908151.1597994149; _gid=GA1.2.137579554.1598335057; _gat=1' --data-raw '{"choiceIds":["5f44a89da6ca932af2b92206"]}'"

service tor start

sleep 2

torsocks curl $url

while executing this script error like this

1598352787 ERROR torsocks[7771]: Unable to resolve. Status reply: 1 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: 'https 1598352787 ERROR torsocks[7771]: Unable to resolve. Status reply: 4 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: Mozilla 1598352787 ERROR torsocks[7771]: Unable to resolve. Status reply: 1 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: (X11; 1598352787 ERROR torsocks[7771]: Unable to resolve. Status reply: 4 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: Linux 1598352787 ERROR torsocks[7771]: Unable to resolve. Status reply: 1 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: x86_64; curl: (3) URL using bad/illegal format or missing URL 1598352788 ERROR torsocks[7771]: Unable to resolve. Status reply: 4 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: Gecko 1598352788 ERROR torsocks[7771]: Unable to resolve. Status reply: 4 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: Firefox 1598352788 ERROR torsocks[7771]: Unable to resolve. Status reply: 1 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: -H 1598352788 ERROR torsocks[7771]: Unable to resolve. Status reply: 1 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: 'Accept 1598352788 ERROR torsocks[7771]: Unable to resolve. Status reply: 4 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: application 1598352788 ERROR torsocks[7771]: Unable to resolve. Status reply: 1 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: -H 1598352788 ERROR torsocks[7771]: Unable to resolve. Status reply: 1 (in socks5_recv_resolve_reply() at socks5.c:677) curl: (6) Could not resolve host: 'Accept-Language

Please guide me to resolve this :)

Upvotes: 0

Views: 830

Answers (1)

redInk
redInk

Reputation: 725

This will help.

#!/bin/bash

url="https://www.polltab.com/api/poll/fhfjyQ4vRJ/vote"
h1="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0"
h2="Accept: application/json"
h3="Referer: https://www.polltab.com/fhfjyQ4vRJ"
h4="Content-Type: application/json"
h5="Origin: https://www.polltab.com"
h6="Connection: keep-alive"
h7="Cookie: _ga=GA1.2.1092908151.1597994149; _gid=GA1.2.137579554.1598335057; _gat=1"
d1="{\"choiceIds\":[\"5f44a89da6ca932af2b92206\"]}"

service tor start

sleep 2

torsocks curl $url -H '$h1' -H '$h2' -H '$h3' --compressed -H '$h4' -H '$h5' -H '$h6' -H '$h7' --data-raw '$d1'

Upvotes: 0

Related Questions