batch-file – 如何测试STDIN是批量终端?
发布时间:2020-12-14 03:59:35 所属栏目:Windows 来源:网络整理
导读:在 shell中我可以这样做: if test -t 0 ; then echo stdin is a tty exit 0fi 我怎么能批量做到这一点? 解决方法 编辑 – 感谢所有测试人员. @echo off timeout 1 2nul nul if errorlevel 1 ( echo input redirected ) else ( echo input is console ) tim
在
shell中我可以这样做:
if test -t 0 ; then echo stdin is a tty exit 0 fi 我怎么能批量做到这一点? 解决方法
编辑 – 感谢所有测试人员.
@echo off timeout 1 2>nul >nul if errorlevel 1 ( echo input redirected ) else ( echo input is console ) timeout命令尝试直接访问控制台,如果执行批处理文件,则会失败 myBatchFile.cmd < input.txt echo something | myBatchFile.cmd 在Windows XP上测试(从W2003 Resource Kit超时),7和8.1. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
推荐文章
站长推荐
- active-directory – 从2008迁移到2012R2域后无法
- windows-server-2008 – Windows Server2008 Rem
- 在Windows 7上启用MySQL 5查询日志
- 使用CodeBlocks开发Win32用户界面程序
- windows-server-2003 – 如何确定MSMQ 3.0容量和
- 什么是Windows上的unbuffer程序?
- windows-phone-7 – WP7中是否有Label控件?
- xaml – 通用App ListView项目Horizo??ntalAlign
- windows-server-2008 – 除了星期日之外,你能创建
- Windows Server 2008 服务器重启后卡死在Windows
热点阅读