简体   繁体   English

如何将脚本的输出复制到Windows剪贴板?

[英]How can I get a script's output to be copied to the Windows clipboard?

I find myself running scripts and copy-pasting the output of these runs into emails or into some other documents. 我发现自己运行脚本并将这些运行的输出复制粘贴到电子邮件或其他文档中。 Is there a way such that I can make the copy-to-clipboard step a part of the script itself? 有没有办法让我可以将复制到剪贴板步骤作为脚本本身的一部分? Most of my scripts are either Perl or bat files and I work on Windows. 我的大多数脚本都是Perl或bat文件,我在Windows上工作。

Thanks. 谢谢。

There's a utility called clip.exe that you can use. 有一个名为clip.exe实用程序 ,您可以使用它。 Just pipe the output of your script or any other command into clip.exe (First, put it on your path somewhere. If you don't have a usual place for these kindss of utilities, you can dump it in the directory you usually run your scripts from, or I've known people to use c:\\Windows\\system32 in a pinch...): 只需将脚本输出或任何其他命令输入到clip.exe中(首先,将它放在你的路径上。如果你没有这些实用程序的通常位置,你可以将它转储到你经常运行的目录中您的脚本,或者我知道人们在紧要关头使用c:\\Windows\\system32 ...):

somescript.bat | clip

Then paste away. 然后粘贴。

在Perl中,安装并使用Win32 :: Clipboard模块

不确定剪贴板,但你可以将输出管道传输到文本文件,但做这样的事情:

somescript.bat > output.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM