Batch-File Stops at first Line or Ends up in Loop
I have a little problem I don't understand. First off I am a Rookie and never done Batch-Scripting before. I made two scripts for my company including the command nslookup
First script: in this script the nslookup command shall print me out the results of a specific ip range, but after "echo NSLOOKUP" nothing is displayed" The for-loop doesn't execute. But it worked last week with the same code:
@echo off
for /L %%x IN (33, 1, 60) DO (
echo _______________________
echo NS LOOKUP
nslookup 192.168.178.%%x
)
pause
Second script: Here it's a bit different. I can enter the name for the domain, but after that it doesnt execute the nslookup-command aswell
@echo off
set input=y
:while
if %input%==n (
exit
)
echo _______________
echo Name for nslookup
set /p name=
nslookup %name%.domain.domain.domain.de
echo _______________
echo Search another one? (y/n)
set /p input=
goto while
Also whenever I make a new batch-file and typing something like:
@echo off
echo tell me your name
set /p name=
echo tell me your age
set /p age=
echo %name%
echo %age%
pause
It just end in a loop with an input of name and age.
I am confused. Please help me. I'd appreciate it. Thank you in advance.
batch-file
add a comment |
I have a little problem I don't understand. First off I am a Rookie and never done Batch-Scripting before. I made two scripts for my company including the command nslookup
First script: in this script the nslookup command shall print me out the results of a specific ip range, but after "echo NSLOOKUP" nothing is displayed" The for-loop doesn't execute. But it worked last week with the same code:
@echo off
for /L %%x IN (33, 1, 60) DO (
echo _______________________
echo NS LOOKUP
nslookup 192.168.178.%%x
)
pause
Second script: Here it's a bit different. I can enter the name for the domain, but after that it doesnt execute the nslookup-command aswell
@echo off
set input=y
:while
if %input%==n (
exit
)
echo _______________
echo Name for nslookup
set /p name=
nslookup %name%.domain.domain.domain.de
echo _______________
echo Search another one? (y/n)
set /p input=
goto while
Also whenever I make a new batch-file and typing something like:
@echo off
echo tell me your name
set /p name=
echo tell me your age
set /p age=
echo %name%
echo %age%
pause
It just end in a loop with an input of name and age.
I am confused. Please help me. I'd appreciate it. Thank you in advance.
batch-file
2
can't replicate any of your problems (and can't imagine a reason for any of them) I guess you don't have a programming issue but a computer issue.
– Stephan
Nov 12 at 11:27
2
Did name the first batchnslookup.bat
?
– LotPings
Nov 12 at 12:51
2
@LotPings I posted that exact same question to OP earlier but then deleted it because what I thought of later was the fact that he said that it worked the previous week, so unless he changed the name. Let's see what he responds with.
– Gerhard Barnard
Nov 12 at 12:58
1
Was also my first thought, but if the name werenslookup.bat
, it wouldn't just stop, but loop echoing-----------
. Same for second script
– Stephan
Nov 12 at 14:30
2
At the top of your script, replace@ECHO OFF
with@ECHO ON
. Now run the batch file from the command prompt instead of executing it with your mouse. Update your question with the output of each batch file.
– Squashman
Nov 12 at 16:02
add a comment |
I have a little problem I don't understand. First off I am a Rookie and never done Batch-Scripting before. I made two scripts for my company including the command nslookup
First script: in this script the nslookup command shall print me out the results of a specific ip range, but after "echo NSLOOKUP" nothing is displayed" The for-loop doesn't execute. But it worked last week with the same code:
@echo off
for /L %%x IN (33, 1, 60) DO (
echo _______________________
echo NS LOOKUP
nslookup 192.168.178.%%x
)
pause
Second script: Here it's a bit different. I can enter the name for the domain, but after that it doesnt execute the nslookup-command aswell
@echo off
set input=y
:while
if %input%==n (
exit
)
echo _______________
echo Name for nslookup
set /p name=
nslookup %name%.domain.domain.domain.de
echo _______________
echo Search another one? (y/n)
set /p input=
goto while
Also whenever I make a new batch-file and typing something like:
@echo off
echo tell me your name
set /p name=
echo tell me your age
set /p age=
echo %name%
echo %age%
pause
It just end in a loop with an input of name and age.
I am confused. Please help me. I'd appreciate it. Thank you in advance.
batch-file
I have a little problem I don't understand. First off I am a Rookie and never done Batch-Scripting before. I made two scripts for my company including the command nslookup
First script: in this script the nslookup command shall print me out the results of a specific ip range, but after "echo NSLOOKUP" nothing is displayed" The for-loop doesn't execute. But it worked last week with the same code:
@echo off
for /L %%x IN (33, 1, 60) DO (
echo _______________________
echo NS LOOKUP
nslookup 192.168.178.%%x
)
pause
Second script: Here it's a bit different. I can enter the name for the domain, but after that it doesnt execute the nslookup-command aswell
@echo off
set input=y
:while
if %input%==n (
exit
)
echo _______________
echo Name for nslookup
set /p name=
nslookup %name%.domain.domain.domain.de
echo _______________
echo Search another one? (y/n)
set /p input=
goto while
Also whenever I make a new batch-file and typing something like:
@echo off
echo tell me your name
set /p name=
echo tell me your age
set /p age=
echo %name%
echo %age%
pause
It just end in a loop with an input of name and age.
I am confused. Please help me. I'd appreciate it. Thank you in advance.
batch-file
batch-file
asked Nov 12 at 8:28
SchnoppDog
1
1
2
can't replicate any of your problems (and can't imagine a reason for any of them) I guess you don't have a programming issue but a computer issue.
– Stephan
Nov 12 at 11:27
2
Did name the first batchnslookup.bat
?
– LotPings
Nov 12 at 12:51
2
@LotPings I posted that exact same question to OP earlier but then deleted it because what I thought of later was the fact that he said that it worked the previous week, so unless he changed the name. Let's see what he responds with.
– Gerhard Barnard
Nov 12 at 12:58
1
Was also my first thought, but if the name werenslookup.bat
, it wouldn't just stop, but loop echoing-----------
. Same for second script
– Stephan
Nov 12 at 14:30
2
At the top of your script, replace@ECHO OFF
with@ECHO ON
. Now run the batch file from the command prompt instead of executing it with your mouse. Update your question with the output of each batch file.
– Squashman
Nov 12 at 16:02
add a comment |
2
can't replicate any of your problems (and can't imagine a reason for any of them) I guess you don't have a programming issue but a computer issue.
– Stephan
Nov 12 at 11:27
2
Did name the first batchnslookup.bat
?
– LotPings
Nov 12 at 12:51
2
@LotPings I posted that exact same question to OP earlier but then deleted it because what I thought of later was the fact that he said that it worked the previous week, so unless he changed the name. Let's see what he responds with.
– Gerhard Barnard
Nov 12 at 12:58
1
Was also my first thought, but if the name werenslookup.bat
, it wouldn't just stop, but loop echoing-----------
. Same for second script
– Stephan
Nov 12 at 14:30
2
At the top of your script, replace@ECHO OFF
with@ECHO ON
. Now run the batch file from the command prompt instead of executing it with your mouse. Update your question with the output of each batch file.
– Squashman
Nov 12 at 16:02
2
2
can't replicate any of your problems (and can't imagine a reason for any of them) I guess you don't have a programming issue but a computer issue.
– Stephan
Nov 12 at 11:27
can't replicate any of your problems (and can't imagine a reason for any of them) I guess you don't have a programming issue but a computer issue.
– Stephan
Nov 12 at 11:27
2
2
Did name the first batch
nslookup.bat
?– LotPings
Nov 12 at 12:51
Did name the first batch
nslookup.bat
?– LotPings
Nov 12 at 12:51
2
2
@LotPings I posted that exact same question to OP earlier but then deleted it because what I thought of later was the fact that he said that it worked the previous week, so unless he changed the name. Let's see what he responds with.
– Gerhard Barnard
Nov 12 at 12:58
@LotPings I posted that exact same question to OP earlier but then deleted it because what I thought of later was the fact that he said that it worked the previous week, so unless he changed the name. Let's see what he responds with.
– Gerhard Barnard
Nov 12 at 12:58
1
1
Was also my first thought, but if the name were
nslookup.bat
, it wouldn't just stop, but loop echoing -----------
. Same for second script– Stephan
Nov 12 at 14:30
Was also my first thought, but if the name were
nslookup.bat
, it wouldn't just stop, but loop echoing -----------
. Same for second script– Stephan
Nov 12 at 14:30
2
2
At the top of your script, replace
@ECHO OFF
with @ECHO ON
. Now run the batch file from the command prompt instead of executing it with your mouse. Update your question with the output of each batch file.– Squashman
Nov 12 at 16:02
At the top of your script, replace
@ECHO OFF
with @ECHO ON
. Now run the batch file from the command prompt instead of executing it with your mouse. Update your question with the output of each batch file.– Squashman
Nov 12 at 16:02
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f53258296%2fbatch-file-stops-at-first-line-or-ends-up-in-loop%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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%2f53258296%2fbatch-file-stops-at-first-line-or-ends-up-in-loop%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
2
can't replicate any of your problems (and can't imagine a reason for any of them) I guess you don't have a programming issue but a computer issue.
– Stephan
Nov 12 at 11:27
2
Did name the first batch
nslookup.bat
?– LotPings
Nov 12 at 12:51
2
@LotPings I posted that exact same question to OP earlier but then deleted it because what I thought of later was the fact that he said that it worked the previous week, so unless he changed the name. Let's see what he responds with.
– Gerhard Barnard
Nov 12 at 12:58
1
Was also my first thought, but if the name were
nslookup.bat
, it wouldn't just stop, but loop echoing-----------
. Same for second script– Stephan
Nov 12 at 14:30
2
At the top of your script, replace
@ECHO OFF
with@ECHO ON
. Now run the batch file from the command prompt instead of executing it with your mouse. Update your question with the output of each batch file.– Squashman
Nov 12 at 16:02