DOS回声%变量%QUOT;回声是ON" [英] DOS echo %variable% "Echo is ON"

查看:134
本文介绍了DOS回声%变量%QUOT;回声是ON"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个DOS批处理文件。

I have a dos batch file.

mycommand.exe>c:\temp
find /B Serv c:\temp>c:\temp2
set /p var1=<c:\temp2
SET var2=%var1:~-7%
echo %var2%

这只是DOS,而不是Windows环境。

的问题是,批处理文件输出是:
回声是ON。不能呼应VAR2变量。

The problem is that, the batch file output is: "Echo is ON". Can't echo the VAR2 variable.

mycommand.exe是一个简单的应用程序。不重要。

mycommand.exe is a simple app. Not important.

> type c:\temp"
VERSION 45.2
TAG1 NUMBER is 1234567
Serv NUMBER is 9654754

> type c:\temp2
c:temp Serv NUMBER is 9654754

我能做些什么,如果我想回应VAR2的变量?
我不能用SETLOCAL enabledelayedexpansion,因为SETLOCAL命令或无法识别文件名。

What can I do, If I would like echo the VAR2 variable? I can't use "setlocal enabledelayedexpansion" because setlocal "Command or filename not recognized".

编辑:那我我想要什么呢?
我想响应去年7 characthers mycommand.exe输出3号线。多数民众赞成。

What am I want exactly? I would like to ECHO mycommand.exe output 3rd line last 7 characthers. Thats all.

推荐答案

好老的DOS是旧的,但不是非常好。

"good old DOS" is old, but not very good.

您可以解决问题,basicly通过建立一个临时.bat文件。

Your problem can be solved, basicly by building a temporary .bat file.

它在这里详细描述:

https://support.microsoft.com/en-us/kb/66292

我没有DOS可用,所以我无法测试,但这应该为你工作:

I have no DOS available, so I can't test, but this should work for you:

mycommand.exe>c:\temp.txt
find "Serv " c:\temp.txt>c:\temp2.txt

REM init.txt should already exist
REM to create it:
REM   COPY CON INIT.TXT
REM   SET VARIABLE=^Z
REM ( press Ctrl-Z to generate ^Z )
REM
REM also the file "temp2.txt" should exist.

copy init.txt+temp2.txt varset.bat
call varset.bat
for %%i in (%variable%) do set numb=%%i
echo Server number is: %numb%
REM just because I'm curious, does the following work? :
set var2=%variable%
echo var2 is now %var2%

init.txt 的手动创建的需要进行一次只是做了,如果你能活着,它总是创建一个变量具有相同的名称(因此最后两行,所以你可以一遍又一遍使用相同的init.txt - 请反馈,无论是它的工作原理 - 我很好奇)

The manual creation of init.txt has to be done once only, if you can live with, that it always creates a variable with the same name (therefore the last two lines, so you could use the same init.txt over and over again - please feedback, whether it works - I'm quite curious)

这篇关于DOS回声%变量%QUOT;回声是ON&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆