I know there are many similar questions arround the Internet, but I couldn't find a solution for my specific problem.
I made this script for an assignment, where I want to find which combinations return UNLOCKED as a result in HTML.
#!/bin/bash for ((x4=0;x4<=4;x4++)); do for ((x3=0;x3<=4;x3++)); do for ((x2=0;x2<=4;x2++)); do for ((x1=0;x1<=4;x1++)); do echo $x1 $x2 $x3 $x4 eval curl http://www.artemiosv.info/21.php?p1=$x1;p2=$x2;p3=$x3;p4=$x4 | grep -oP '<BODY>*[\s\S]*</BODY>' done done done done
The first lines of the result it returns, after redirecting the script's output in a file, is:
0 0 0 0 <HTML><BODY>LOCKED</BODY></HTML>1 0 0 0 <HTML><BODY>LOCKED</BODY></HTML>2 0 0 0 <HTML><BODY>LOCKED</BODY></HTML>3 0 0 0
From the HTML code, which is the actual result of the curl command, I want only the main text, in the case of those lines LOCKED. But the regex I used doesn't seem to work, while testing the same pattern outside of script works fine. The expected results from HTML should be LOCKED, UNLOCKED and I think YOU FOUND THE SECRET.
Why grep has this issue inside script and outside works fine? How can I fix it?