Batch命令通过批处理命令将多行内容粘贴为输入。

huangapple go评论56阅读模式
英文:

Batch command paste several lines as input via Batch command

问题

我正在编写一个自动解密用户粘贴的邮件的脚本。

@echo off
REM 创建一个以邮件名称命名的文本文件
set /p textfileName=您想要邮件的文件名是什么?

REM 创建文本文件的内容
@echo 在下面的行上粘贴您收到的邮件的内容。
set /p textfileContents=

REM 将内容写入文本文件
@echo %textfileContents% > %textfileName%.txt
@echo 您的文件已创建并位于与此批处理文件相同的目录中。
@echo 它的名字是 %textfilename%.txt

REM 使用 gnupg 解密文本文件
gpg --output %textfilename% --decrypt doc.gpg

我的问题是,我希望用户能够粘贴一个多行的加密邮件。每次我尝试运行脚本时,它只使用粘贴的邮件的第一行。

因此,如果我粘贴:

hQIMA/G0CbVUEcdqAQ/9HwDqyk8xfQDdF/6iogMs7u3eW/6wMTGG8p3RawPKttbU
yduQF6lcF3diMHh2yBU93HAcU0xFL5mysm1AKQGYQSNaB5KheG2hSet80ViQePqy

它只使用:

hQIMA/G0CbVUEcdqAQ/9HwDqyk8xfQDdF/6iogMs7u3eW/6wMTGG8p3RawPKttbU

有没有办法将多行粘贴作为输入?

英文:

I am currently writing a script that automatically decrypts a mail that a user pastes.

@echo off
REM create a textfile with the name of the mail
set /p textfileName=What would you like the mail to be named? 

REM create contents of the textdocument
@echo On the line below copy the contents of your mail that you received.
set /p textfileContents= 

REM write the contents to textfile
@echo %textfileContents% > %textfileName%.txt
@echo Your file has been created and is in the same directory as this batch file.
@echo It is named %textfilename%.txt

REM decrypting the textfile with gnupg
gpg --output %textfilename% --decrypt doc.gpg

My problem is that I want the user to be able to paste a multi line mail that is encrypted. Every time I try the script it only uses the first line that was pasted.

So if I paste:

hQIMA/G0CbVUEcdqAQ/9HwDqyk8xfQDdF/6iogMs7u3eW/6wMTGG8p3RawPKttbU
yduQF6lcF3diMHh2yBU93HAcU0xFL5mysm1AKQGYQSNaB5KheG2hSet80ViQePqy

It only uses:

hQIMA/G0CbVUEcdqAQ/9HwDqyk8xfQDdF/6iogMs7u3eW/6wMTGG8p3RawPKttbU

Is there a ways to paste several lines as an input?

答案1

得分: 0

(
 SET /p line1=请输入任何内容
 SET /p line2=
 )<con

ECHO -------------
ECHO %line1%
ECHO -------------
ECHO %line2%

应该可以实现你想要的功能。Windows可能会阻止尝试从剪贴板粘贴多行内容,你可能需要在粘贴数据后按 Enter 键。

英文:
(
 SET /p line1=Please enter whatever
 SET /p line2=
)&lt;con

ECHO -------------
ECHO %line1%
ECHO -------------
ECHO %line2%

Should do what you want. Windows may object to trying to paste more than one line from the clipboard and you'll probably need to press <kbd>Enter</kbd> having pasted the data.

huangapple
  • 本文由 发表于 2023年2月8日 08:30:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/75380331.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定