i need generate number values and uses that values on curl. i have done this but the code have some faults because can’t generate the numbers.
#!/bin/bash
for a in $(seq 0 9)
do
pass[0]="$a"
for b in $(seq 0 9)
do
pass[1]="$b"
for c in $(seq 0 9)
do
pass[2]="$c"
for d in $(seq 0 9)
do
pass[3]="$d"
for e in $(seq 0 9)
do
pass[4]="$e"
for f in $(seq 0 9)
do
pass[5]="$f"
curl -d "$a$b$c$d$e$f" somesite.php
done
done
done
done
done
done
i get this output:
echo ${pass[*}
> done
>
Display all 289 possibilities? (y or n)
> e
> done
> done
> done
> done
> ^C
Simpler (but still ghastly):
I’m not convinced that the script you copied to the question is the one you executed. When I do run your script, it executes commands like:
Note the spaces; I suspect they are (a) unwanted and (b) largely unavoidable without futzing with IFS, which is worse than fixing the code as I showed. Arrays are great; they aren’t for everything.
Incidentally, it would be simpler (by far) to use:
or:
or … there are other ways to do it too (see other answers). The
seq | while readloop has the advantage of not needing more than 7 MiB of memory to store the numbers.It’s going to take a while to
curlone million pages.