Why “ECHO is off” is printed?
up vote
0
down vote
favorite
I am expecting to receive just an output "NO User exists for *" after running this code:
FOR /F "tokens=* delims= " %%A IN ('C:windowsSystem32query.exe user /server:<some_IP_address>') DO SET NumDoc1=%%A
echo %NumDoc1%
But I keep getting:
No User exists for *
ECHO is off.
How do I get rid of "ECHO is off" from my output?
Thanks
batch-file command-line
add a comment |
up vote
0
down vote
favorite
I am expecting to receive just an output "NO User exists for *" after running this code:
FOR /F "tokens=* delims= " %%A IN ('C:windowsSystem32query.exe user /server:<some_IP_address>') DO SET NumDoc1=%%A
echo %NumDoc1%
But I keep getting:
No User exists for *
ECHO is off.
How do I get rid of "ECHO is off" from my output?
Thanks
batch-file command-line
1
Must mean your environment variable is blank.
– shawnt00
Nov 8 at 23:38
Why are you asking for all tokens, but then delimiting on spaces?
– Compo
Nov 9 at 0:22
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am expecting to receive just an output "NO User exists for *" after running this code:
FOR /F "tokens=* delims= " %%A IN ('C:windowsSystem32query.exe user /server:<some_IP_address>') DO SET NumDoc1=%%A
echo %NumDoc1%
But I keep getting:
No User exists for *
ECHO is off.
How do I get rid of "ECHO is off" from my output?
Thanks
batch-file command-line
I am expecting to receive just an output "NO User exists for *" after running this code:
FOR /F "tokens=* delims= " %%A IN ('C:windowsSystem32query.exe user /server:<some_IP_address>') DO SET NumDoc1=%%A
echo %NumDoc1%
But I keep getting:
No User exists for *
ECHO is off.
How do I get rid of "ECHO is off" from my output?
Thanks
batch-file command-line
batch-file command-line
asked Nov 8 at 23:36
JerryH
32
32
1
Must mean your environment variable is blank.
– shawnt00
Nov 8 at 23:38
Why are you asking for all tokens, but then delimiting on spaces?
– Compo
Nov 9 at 0:22
add a comment |
1
Must mean your environment variable is blank.
– shawnt00
Nov 8 at 23:38
Why are you asking for all tokens, but then delimiting on spaces?
– Compo
Nov 9 at 0:22
1
1
Must mean your environment variable is blank.
– shawnt00
Nov 8 at 23:38
Must mean your environment variable is blank.
– shawnt00
Nov 8 at 23:38
Why are you asking for all tokens, but then delimiting on spaces?
– Compo
Nov 9 at 0:22
Why are you asking for all tokens, but then delimiting on spaces?
– Compo
Nov 9 at 0:22
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
When no users are found, the output is being sent to Standard Error. The FOR command is just capturing Standard Output. So you need to redirect Standard Error to Standard output.
for /f "delims=" %%G IN ('"query user /server:servername 2>&1"') do set NumDoc1=%%G
Thank you @Squashman! This works wonderfully.
– JerryH
Nov 12 at 17:41
@JerryH, please read What should I do when someone answers my question?
– Squashman
Nov 12 at 18:04
add a comment |
up vote
3
down vote
You are echo
ing the current echo
status because your variable is empty.
Try this instead:
echo NumDoc1:%NumDoc1%
I tried your way, and it just displays this now: No User exists for * NumDoc1:
– JerryH
Nov 9 at 0:06
That is the expected outcome. This is because NumDoc1 contains no value. I understand theECHO is off.
status message no longer appears?
– pcgben
Nov 9 at 0:16
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
When no users are found, the output is being sent to Standard Error. The FOR command is just capturing Standard Output. So you need to redirect Standard Error to Standard output.
for /f "delims=" %%G IN ('"query user /server:servername 2>&1"') do set NumDoc1=%%G
Thank you @Squashman! This works wonderfully.
– JerryH
Nov 12 at 17:41
@JerryH, please read What should I do when someone answers my question?
– Squashman
Nov 12 at 18:04
add a comment |
up vote
3
down vote
accepted
When no users are found, the output is being sent to Standard Error. The FOR command is just capturing Standard Output. So you need to redirect Standard Error to Standard output.
for /f "delims=" %%G IN ('"query user /server:servername 2>&1"') do set NumDoc1=%%G
Thank you @Squashman! This works wonderfully.
– JerryH
Nov 12 at 17:41
@JerryH, please read What should I do when someone answers my question?
– Squashman
Nov 12 at 18:04
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
When no users are found, the output is being sent to Standard Error. The FOR command is just capturing Standard Output. So you need to redirect Standard Error to Standard output.
for /f "delims=" %%G IN ('"query user /server:servername 2>&1"') do set NumDoc1=%%G
When no users are found, the output is being sent to Standard Error. The FOR command is just capturing Standard Output. So you need to redirect Standard Error to Standard output.
for /f "delims=" %%G IN ('"query user /server:servername 2>&1"') do set NumDoc1=%%G
answered Nov 9 at 0:23
Squashman
8,26731932
8,26731932
Thank you @Squashman! This works wonderfully.
– JerryH
Nov 12 at 17:41
@JerryH, please read What should I do when someone answers my question?
– Squashman
Nov 12 at 18:04
add a comment |
Thank you @Squashman! This works wonderfully.
– JerryH
Nov 12 at 17:41
@JerryH, please read What should I do when someone answers my question?
– Squashman
Nov 12 at 18:04
Thank you @Squashman! This works wonderfully.
– JerryH
Nov 12 at 17:41
Thank you @Squashman! This works wonderfully.
– JerryH
Nov 12 at 17:41
@JerryH, please read What should I do when someone answers my question?
– Squashman
Nov 12 at 18:04
@JerryH, please read What should I do when someone answers my question?
– Squashman
Nov 12 at 18:04
add a comment |
up vote
3
down vote
You are echo
ing the current echo
status because your variable is empty.
Try this instead:
echo NumDoc1:%NumDoc1%
I tried your way, and it just displays this now: No User exists for * NumDoc1:
– JerryH
Nov 9 at 0:06
That is the expected outcome. This is because NumDoc1 contains no value. I understand theECHO is off.
status message no longer appears?
– pcgben
Nov 9 at 0:16
add a comment |
up vote
3
down vote
You are echo
ing the current echo
status because your variable is empty.
Try this instead:
echo NumDoc1:%NumDoc1%
I tried your way, and it just displays this now: No User exists for * NumDoc1:
– JerryH
Nov 9 at 0:06
That is the expected outcome. This is because NumDoc1 contains no value. I understand theECHO is off.
status message no longer appears?
– pcgben
Nov 9 at 0:16
add a comment |
up vote
3
down vote
up vote
3
down vote
You are echo
ing the current echo
status because your variable is empty.
Try this instead:
echo NumDoc1:%NumDoc1%
You are echo
ing the current echo
status because your variable is empty.
Try this instead:
echo NumDoc1:%NumDoc1%
answered Nov 8 at 23:40
pcgben
498415
498415
I tried your way, and it just displays this now: No User exists for * NumDoc1:
– JerryH
Nov 9 at 0:06
That is the expected outcome. This is because NumDoc1 contains no value. I understand theECHO is off.
status message no longer appears?
– pcgben
Nov 9 at 0:16
add a comment |
I tried your way, and it just displays this now: No User exists for * NumDoc1:
– JerryH
Nov 9 at 0:06
That is the expected outcome. This is because NumDoc1 contains no value. I understand theECHO is off.
status message no longer appears?
– pcgben
Nov 9 at 0:16
I tried your way, and it just displays this now: No User exists for * NumDoc1:
– JerryH
Nov 9 at 0:06
I tried your way, and it just displays this now: No User exists for * NumDoc1:
– JerryH
Nov 9 at 0:06
That is the expected outcome. This is because NumDoc1 contains no value. I understand the
ECHO is off.
status message no longer appears?– pcgben
Nov 9 at 0:16
That is the expected outcome. This is because NumDoc1 contains no value. I understand the
ECHO is off.
status message no longer appears?– pcgben
Nov 9 at 0:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217762%2fwhy-echo-is-off-is-printed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Must mean your environment variable is blank.
– shawnt00
Nov 8 at 23:38
Why are you asking for all tokens, but then delimiting on spaces?
– Compo
Nov 9 at 0:22