ren jia
ren jia

Reputation: 1

how can I pass a json as a command after -x in wscat

I need to use a json as the command after -x in wscat. however it returns wrong format from the server.

my script is just like this:


#!/usr/bin/env bash

read -p "param1:" param1
read -p "param2:" param2

json=$(cat <<-END
{
   "param1": "${param1}",\
   "param2": "${param2}"\
}
END
)

wscat -c \<wss_host\> -x $json

this gives me error saying "invalid json request".

running sh -x <myscript>, i found i got below request in the end:
wscat -c <wss_host> -x '{' '"param1":' '"<param1 i put>",' '"param2":' '"<param1 i put>"' '}'

=> is it because my json is not parsed correctly?
i was expecting something like {"param1":"<param1 i put>","param2":"<param1 i put>"}
but not: '{' '"param1":' '"<param1 i put>",' '"param2":' '"<param1 i put>"' '}' <= there are some extra single quotes

would youd kindly advise? thank you !

yours sincerely, jiaren

i am really running out of ideas..

Upvotes: 0

Views: 15

Answers (0)

Related Questions