【发布时间】:2018-08-10 03:19:28
【问题描述】:
我需要在ffmpeg --header 参数中使用\r\n。这适用于 Unix,但不适用于 Windows 命令提示符。所以我想使用powershell
powershell c:\ffmpeg -headers 'User-Agent: user-agent'"`r`n"'Cookies: my-cookie' ...
我知道当使用特殊字符时我必须使用'string' 并且
"`r`n"
作为我的\r\n 分隔符。
我还测试了我可以将它们混合在一起,比如'this '"is "'text' 得到this is text
但是,如果我的字符串(cookie 或用户代理)包含 & 字符,则会失败。
示例:powershell c:\ffmpeg -headers 'Cookies: param=a=1&b=2; session=123'
如何在单行中“转义”& 字符?
这些示例(某些部分被屏蔽)被 CMD 接受,但它们不起作用
powershell -c "c:\ffplay -user_agent ""Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0"" -headers ""Cookie: nlqptid=h=676886edeea5bae904b0cf53daec8038.1519940538670&hdnea=exp=1519940598~acl=/*~hmac=C0E019502B060D23AB02BB157FCFFC72404500770A2CE5B00789A84AAEFBD77F&nltid=xxxxxxxxxx&nltdt=0&uid=744826&csid=xxxxxxxxxx; hdntl=exp=1520026938~acl=%2f*~hmac=952689e6de57a2a201ddc1d4c0794962fdc886ea48cf41494a42e787ef923bf9`r`n"" -i ""https://xxxxxxxxxx.net/nlds_vod/xxxxxxxxxx/vod/2018/02/28/cd264e10-dd54-3de2-df90-4c1cac104dcb/v1/stream/cd264e10-dd54-3de2-df90-4c1cac104dcb_1_4500_pc.mp4.m3u8"""
或
powershell -c "c:\ffplay -headers ""User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:56.0) Gecko/20100101 Firefox/56.0`r`nCookie: nlqptid=h=676886edeea5bae904b0cf53daec8038.1519940538670&hdnea=exp=1519940598~acl=/*~hmac=C0E019502B060D23AB02BB157FCFFC72404500770A2CE5B00789A84AAEFBD77F&nltid=xxxxxxxxxx&nltdt=0&uid=744826&csid=xxxxxxxxxx; hdntl=exp=1520026938~acl=%2f*~hmac=952689e6de57a2a201ddc1d4c0794962fdc886ea48cf41494a42e787ef923bf9`r`n"" -i ""https://xxxxxxxxxx.net/nlds_vod/xxxxxxxxxx/vod/2018/02/28/cd264e10-dd54-3de2-df90-4c1cac104dcb/v1/stream/cd264e10-dd54-3de2-df90-4c1cac104dcb_1_4500_pc.mp4.m3u8"""
ffplay 说
必须指定输入文件
但是输入文件是在-i参数之后指定的。
这个命令有什么问题?
请注意,该实现是现有批处理脚本的一部分,因此需要使用批处理文件内部的语法。
【问题讨论】:
标签: powershell cmd escaping ampersand quoting