Search found 31 matches

by lockedscope
18 Jul 2020 14:48
Forum: DOS Batch Forum
Topic: Writing to handle 3...? (Accessing cmd.exe handles 1,2,3... programmatically)
Replies: 2
Views: 3814

Re: Writing to handle 3...?

I have following .Net(C#) code finally. Hope someone could make benefit from it. Actually my purpose is to understand how handles are written without experimenting with chained redirections but writing to them directly from a command/application. - Instead of Process Explorer handle from SysInternal...
by lockedscope
18 Jul 2020 08:31
Forum: DOS Batch Forum
Topic: Writing to handle 3...? (Accessing cmd.exe handles 1,2,3... programmatically)
Replies: 2
Views: 3814

Writing to handle 3...? (Accessing cmd.exe handles 1,2,3... programmatically)

I tried to write handle 3 with following. There is no way to write directly to handle 3 so i create a file to with the hope of writing to handle 3 but it does not work! It works fine for handle 1 and handle 2. using Microsoft.Win32.SafeHandles; using System; using System.Collections.Generic; using S...
by lockedscope
18 Jul 2020 05:18
Forum: DOS Batch Forum
Topic: Which handle is written to stdout?
Replies: 0
Views: 19784

Which handle is written to stdout?

- 1. In the following, how do we decide which handle is written to stdout, handle 2 or handle 4? :?: I think redirections are sorted for target handles in ascending order because Interpretation 1 should fail with duplication error when we try 1>&4. So, interpretation 2 works when 1>&2 applied and th...
by lockedscope
18 Jul 2020 03:31
Forum: DOS Batch Forum
Topic: How redirections work through pipe?
Replies: 1
Views: 2791

How redirections work through pipe?

Handle2 writes to console because stderr is connected to stdout by default. Is this right? :?: And piped commands could only read from stdin which comes from the stdout of the piping command. So, stderr is not connected to stdout when piping. Is this right? :?: ( echo Output1 echo Output2 >&2 ) echo...
by lockedscope
17 Jul 2020 15:24
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

Thanks Dave. I thought about running algorithm in block statements but not so careful and missed the handle 5s case.
by lockedscope
17 Jul 2020 15:12
Forum: DOS Batch Forum
Topic: How to use chained redirections?
Replies: 24
Views: 24063

Re: How to use chained redirections?

@penpen check this for the algorithm using duplicate handle and force duplicate handle.

Art of assembly book, chapter 19.1.5 Redirection of I/O for Child Processes

https://www.plantation-productions.com/ ... HEADING3-4
by lockedscope
17 Jul 2020 12:19
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

So, i mixed up things in previous post. After reading https://www.dostips.com/forum/viewtopic.php?t=6610&start=15#p43422 , i could understand it better but still have some suspicions. This one is fine. ( echo Output1 echo Output2 >&2 echo Output3 >&3 echo Output4 >&4 echo Output5 >&5 ) 1>&2 2>&3 | (...
by lockedscope
16 Jul 2020 11:50
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

Hi Aacini, Actually i want to lean how this stuff works and i am not sure i learned with well after trying your sample. I tried it with following to understand what is happening. Error is redirected to standard input or output :) but not sure about inner mechanics. So could you explain it please. @e...
by lockedscope
16 Jul 2020 07:11
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

Thank you Aacini for the answer, i will check that article.
Aacini wrote:
16 Jul 2020 06:18
I suggest you to read this thread about using several standard handles to read several input files.

Antonio
by lockedscope
16 Jul 2020 06:53
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

I learned mechanics of redirections from dbenham's explanations at https://www.dostips.com/forum/viewtopic.php?p=14612#p14612 So, i come up with following it works fine but handles seem to be messed up as penpen told and it could not read stdin when it's launched again. @echo off setlocal EnableDela...
by lockedscope
16 Jul 2020 03:06
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

hi penpen, thanks for the comprehensive answer. :D :wink: I tried following and some other variations to reset stdin at the end but it did not help. How could we restore handles at the end to terminate smoothly without exiting cmd.exe instance? (echo off) 5<variables.txt endlocal I realized that it ...
by lockedscope
15 Jul 2020 09:57
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

That's good. I have the batch file calling itself version.
But I am still curios why go-to does not work and why the second one works but exits.
by lockedscope
15 Jul 2020 07:47
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

Re: loop without for to read lines of a file

I could achieve it with following but it exits current command line without any error(may be the weird redirection is culprit) so i call it with cmd/c bat.cmd. So why does it exit? Do you have any idea? bat.cmd @echo off setlocal EnableDelayedExpansion set "ndx=0" (@echo off<&4 4<&3) 3<variables.txt...
by lockedscope
15 Jul 2020 05:53
Forum: DOS Batch Forum
Topic: loop without for to read lines of a file
Replies: 15
Views: 14358

loop without for to read lines of a file

I use following to read from a file but it does not continue reading after first line. I do not want to use a for-loop and want to experiment with set/p. So, how could i achieve reading from a file in a loop(without for-loop)? I tried staged redirection but failed. @echo off setlocal EnableDelayedEx...
by lockedscope
25 Jun 2020 14:34
Forum: DOS Batch Forum
Topic: caret removes the first command after opening parenthesis if its concat'd to the first token of command without space
Replies: 4
Views: 5548

Re: caret removes the first command after opening parenthesis if its concat'd to the first token of command without spac

Another workaround is to redefine parenthesis :) ; - opening parenthesis with the escaped (!& and - a command delimiter - with the escaped !& Rules: - First command could be on the same line as opening parenthesis or on the next line without any space between. - It works when there is a space betwee...