通过WGET作为DATA发送多行命令输出
我正在尝试运行一个命令,该命令将发送带有另一个命令结果的数据的发布请求。一个示例会说明这一点:
wget -O- --post-data=$(ls -lah) http://192.168.30.53/api/v2/network/clients
这显然是错误的,但是我不知道如何“逃脱” ls -lah
命令的值,然后再将其作为参数传递。
如果需要,当前输出:
wget: invalid option -- '>'
wget: --wait: Invalid time period '-r--r--'
I'm trying to run a command that will send a POST request with data that is a result of another command. An example will say it all:
wget -O- --post-data=$(ls -lah) http://192.168.30.53/api/v2/network/clients
This is obviously wrong, but I have no idea how to "escape" the value of ls -lah
command before passing it as a parameter.
Current output if needed:
wget: invalid option -- '>'
wget: --wait: Invalid time period '-r--r--'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不会逃脱 - 您引用了用法。使用ShellCheck检查您的脚本。
You do not escape - you quote the usage. Check your scripts with shellcheck.
wget
man page描述
- post-data =字符串
和- post-file = file
insison,与这种情况相关的是那
,因为上述限制管道STDIN将行不通,但这不是问题,除非您禁止您创建正常文件 - 只需为那就
应该起作用(我没有测试的能力)
wget
man page describe--post-data=string
and--post-file=file
in unison, relevant for this case is thatand that
due to above limitation piping stdin would not work, but that is not problem unless you are banning from creating normal files - just create temporary file for that, something like that
should work (I do not have ability to test it)