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

心不动则不痛 提交于 2019-12-06 02:25:52

问题


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.

Thanks.


回答1:


There's a utility called clip.exe that you can use. 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...):

somescript.bat | clip

Then paste away.




回答2:


In Perl, install and use Win32::Clipboard module




回答3:


Not sure about the clipboard but you can pipe the output to a text file but doing something like this:

somescript.bat > output.txt


来源:https://stackoverflow.com/questions/307658/how-can-i-get-a-scripts-output-to-be-copied-to-the-windows-clipboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!