I try to run this command in a bash script, but I always get errors.
if I do this manually it works
/usr/bin/curl -u :cbftp -s -X POST https://localhost:55477/raw -d '{"command": "site search test", "sites": ["homeftp"]}' --insecure | tail -n +6 | head -n -3
the output is:
{
"failures": [],
"successes": [
{
"name": "homeftp",
"result": "200- Found 1 entries in index (limit 50):\r\n200- /home/user/test\r\n200 Search complete\r\n"
}
]
so it is in the script
#!/bin/bash
search=$1
ftp=$2
gosearch=$(/usr/bin/curl -u :cbftp -s -X POST https://localhost:55477/raw -d '{\"command\": \"site search $search\", \"sites\": [\"$ftp\"]}' --insecure | tail -n +6 | head -n -3)
echo "$gosearch"
so i get the error:
{
"error": "[json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing object key - invalid literal; last read: '{\\'; expected string literal"
}
I suspect it is a special character that should not be used
I want the output like this:
"result": "200- Found 1 entries in index (limit 50):\r\n200- /home/user/test\r\n200 Search complete\r\n"