将curl 与命令文件一起使用
我正在使用 BASH shell 中的curl。我想创建一个通过curl 发送的命令文本文件,然后以某种方式让所有命令同时运行。我已经很长时间没有处理 UNIX 命令了,但是有人可以告诉我如何完成这个任务吗(假设我创建了一个名为commands.txt 的文件)?
编辑这篇文章以包含我想批量执行的命令文件的示例......
curl -XPUT 'http://localhost:9200/foo/property/1' -d '{"firstName":"Domino","lastName":"Derval"}'
curl -XPUT 'http://localhost:9200/foo/property/2' -d '{"firstName":"Elektra","lastName":"King"}'
curl -XPUT 'http://localhost:9200/foo/property/3' -d '{"firstName":"Fiona","lastName":"Volpe"}'
curl -XPUT 'http://localhost:9200/foo/property/4' -d '{"firstName":"Holly","lastName":"Goodhead"}'
curl -XPUT 'http://localhost:9200/foo/property/5' -d '{"firstName":"Honey","lastName":"Rider"}'
curl -XPUT 'http://localhost:9200/foo/property/6' -d '{"firstName":"Jill","lastName":"Masterton"}'
curl -XPUT 'http://localhost:9200/foo/property/7' -d '{"firstName":"Kissy","lastName":"Suzuki"}'
curl -XPUT 'http://localhost:9200/foo/property/8' -d '{"firstName":"Mary","lastName":"Goodnight"}'
curl -XPUT 'http://localhost:9200/foo/property/9' -d '{"firstName":"Miranda","lastName":"Frost"}'
curl -XPUT 'http://localhost:9200/foo/property/10' -d '{"firstName":"Molly","lastName":"Warmflash"}'
curl -XPUT 'http://localhost:9200/foo/property/11' -d '{"firstName":"Paula","lastName":"Caplan"}'
curl -XPUT 'http://localhost:9200/foo/property/12' -d '{"firstName":"Penelope","lastName":"Smallbone"}'
curl -XPUT 'http://localhost:9200/foo/property/13' -d '{"firstName":"Pussy","lastName":"Galore"}'
curl -XPUT 'http://localhost:9200/foo/property/14' -d '{"firstName":"Strawberry","lastName":"Fields"}'
curl -XPUT 'http://localhost:9200/foo/property/15' -d '{"firstName":"Sylvia","lastName":"Trench"}'
curl -XPUT 'http://localhost:9200/foo/property/16' -d '{"firstName":"Tatiana","lastName":"Romanova"}'
curl -XPUT 'http://localhost:9200/foo/property/17' -d '{"firstName":"Tilly","lastName":"Masterton"}'
curl -XPUT 'http://localhost:9200/foo/property/18' -d '{"firstName":"Vesper","lastName":"Lynd"}'
curl -XPUT 'http://localhost:9200/foo/property/19' -d '{"firstName":"Xenia","lastName":"Onatopp"}'
I am using curl from a BASH shell. I would like to create a text file of commands to send via curl and then somehow have all of them run at once. It's been a long time since I dealt with UNIX commands, but can someone show me how to accomplish this please (assuming I have a file created called commands.txt)?
Editing this post to include an example of the file of commands I would like to execute in batch...
curl -XPUT 'http://localhost:9200/foo/property/1' -d '{"firstName":"Domino","lastName":"Derval"}'
curl -XPUT 'http://localhost:9200/foo/property/2' -d '{"firstName":"Elektra","lastName":"King"}'
curl -XPUT 'http://localhost:9200/foo/property/3' -d '{"firstName":"Fiona","lastName":"Volpe"}'
curl -XPUT 'http://localhost:9200/foo/property/4' -d '{"firstName":"Holly","lastName":"Goodhead"}'
curl -XPUT 'http://localhost:9200/foo/property/5' -d '{"firstName":"Honey","lastName":"Rider"}'
curl -XPUT 'http://localhost:9200/foo/property/6' -d '{"firstName":"Jill","lastName":"Masterton"}'
curl -XPUT 'http://localhost:9200/foo/property/7' -d '{"firstName":"Kissy","lastName":"Suzuki"}'
curl -XPUT 'http://localhost:9200/foo/property/8' -d '{"firstName":"Mary","lastName":"Goodnight"}'
curl -XPUT 'http://localhost:9200/foo/property/9' -d '{"firstName":"Miranda","lastName":"Frost"}'
curl -XPUT 'http://localhost:9200/foo/property/10' -d '{"firstName":"Molly","lastName":"Warmflash"}'
curl -XPUT 'http://localhost:9200/foo/property/11' -d '{"firstName":"Paula","lastName":"Caplan"}'
curl -XPUT 'http://localhost:9200/foo/property/12' -d '{"firstName":"Penelope","lastName":"Smallbone"}'
curl -XPUT 'http://localhost:9200/foo/property/13' -d '{"firstName":"Pussy","lastName":"Galore"}'
curl -XPUT 'http://localhost:9200/foo/property/14' -d '{"firstName":"Strawberry","lastName":"Fields"}'
curl -XPUT 'http://localhost:9200/foo/property/15' -d '{"firstName":"Sylvia","lastName":"Trench"}'
curl -XPUT 'http://localhost:9200/foo/property/16' -d '{"firstName":"Tatiana","lastName":"Romanova"}'
curl -XPUT 'http://localhost:9200/foo/property/17' -d '{"firstName":"Tilly","lastName":"Masterton"}'
curl -XPUT 'http://localhost:9200/foo/property/18' -d '{"firstName":"Vesper","lastName":"Lynd"}'
curl -XPUT 'http://localhost:9200/foo/property/19' -d '{"firstName":"Xenia","lastName":"Onatopp"}'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建脚本
download.sh
使
download.sh
可执行运行
donwload.sh
create a script
download.sh
make
download.sh
executablerun
donwload.sh