This has been covered in previous threads, but I never saw what I just accidentally did.
I opened a file in notepad using the command-line like so:
notepad filename.bat
but I accidentally had |more after it (because I originally used type vs notepad):
notepad filename.bat|more
The result was that the command prompt waited until I closed notepad before continuing. I definitely didn't expect that.
I ran this under the XP command prompt. Hope someone finds this useful.
Pausing Batch File Execution for External Program
Moderator: DosItHelp
Re: Pausing Batch File Execution for External Program
It's the normal behaviour that cmd.exe executes the command lines of a batch file synchronously. It will also work without the pipe to MORE.
If you want it to work asynchronously you have to use the START command.
Regards
aGerman
If you want it to work asynchronously you have to use the START command.
Regards
aGerman
Re: Pausing Batch File Execution for External Program
@aGerman
This is true for batch scripts, but i think he meant from the dos shell, where it is not the normal behavior.
@Samir
You may use this in some cases, for example if you want to create some sample data text files:
You just need a multiline input field, as example this html edit field, and create some sample files using notepad:
Then just mark all, copy it to the clipboard (ctrl+c) and paste it to a dos shell window (right click, insert).
The result is it opens one notepad after the other: I don't like it if there are 10 or 20 files open at the same time.
So i often do it this way, if the sample text could not be automated.
penpen
Edit: Sorry forgotten: But you could have expected it, think of the behavior of more and the pipe operator.
This is true for batch scripts, but i think he meant from the dos shell, where it is not the normal behavior.
@Samir
You may use this in some cases, for example if you want to create some sample data text files:
You just need a multiline input field, as example this html edit field, and create some sample files using notepad:
Code: Select all
notepad sample1.txt |more
notepad sample2.txt |more
notepad sample3.txt |more
notepad sample4.txt |more
...
notepad sampleN.txt |more
The result is it opens one notepad after the other: I don't like it if there are 10 or 20 files open at the same time.
So i often do it this way, if the sample text could not be automated.
penpen
Edit: Sorry forgotten: But you could have expected it, think of the behavior of more and the pipe operator.
Last edited by penpen on 09 Sep 2013 17:45, edited 1 time in total.
Re: Pausing Batch File Execution for External Program
I forgot about that. You're absolutely right that it's normal behavior in batch. I just didn't expect that behavior from the command prompt.aGerman wrote:It's the normal behaviour that cmd.exe executes the command lines of a batch file synchronously. It will also work without the pipe to MORE.
If you want it to work asynchronously you have to use the START command.
Regards
aGerman
Exactly. I accidentally did this in a command prompt.penpen wrote:@aGerman
This is true for batch scripts, but i think he meant from the dos shell, where it is not the normal behavior.
@Samir
You may use this in some cases, for example if you want to create some sample data text files:
You just need a multiline input field, as example this html edit field, and create some sample files using notepad:Then just mark all, copy it to the clipboard (ctrl+c) and paste it to a dos shell window (right click, insert).Code: Select all
notepad sample1.txt |more
notepad sample2.txt |more
notepad sample3.txt |more
notepad sample4.txt |more
...
notepad sampleN.txt |more
The result is it opens one notepad after the other: I don't like it if there are 10 or 20 files open at the same time.
So i often do it this way, if the sample text could not be automated.
penpen
Very interesting use penpen. I usually just let a bunch of notepads open up, but you're right that this trick does have some use when you have to edit a bunch of files in sequence.