我正在尝试下载一个使用半可预测url的网站,这意味着url总是以一个随机的五个字符字母数字字符串结尾。通过使用以下命令,我创建了一个带有随机字符串的具有crunch的文件:
crunch 5 5 abcdefghijklmnopqrstuvwxyz123456789 > possible_links
然后,我创建了一个bash文件来调用这些行并获取链接:
#!/bin/bash
FILE=possible_links
while read line; do
wget -q --wait=20 www.ghostbin.com/paste/${line}
done < $FILE
但很明显,它要去aaaad,然后aaaab,然后aaaac,aaaad,等等,有办法让它走向随机线吗?
发布于 2016-05-29 04:23:04
使用mktemp --dry-run
选项:
#!/bin/bash
while true # or specify a count using something like while [ $count -le 20 ]
do
rand_str="$(mktemp --dry-run XXXXX)" # 5 Xs for five random characters
wget -q --wait=20 www.ghostbin.com/paste/${rand_str}
# if you use count increment count ie do '((count++))' else you get infinite loop
done
通解(n个随机字符)
str=$(printf "%-10s" "X") # here n=10
while condition
do
rand_str=$(mktemp --dry-run ${str// /X})
.
.
https://stackoverflow.com/questions/37506050
复制相似问题