Search found 1041 matches

by jeb
16 Jul 2020 12:14
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 7877

Re: Assign cmdline output to var with inner cmdline quotes?

Hi pstein, did you test your code with the macro from SO:Assign output of a program to a variable ? It should work without any modifications. The FOR/F loop uses a single quote and a double quote for /F "delims=" %%O in ('"%%~2 | findstr /N ^^"') do ( %\n% --- For beter visibility: ... %%O in ( ' " ...
by jeb
13 Jul 2020 01:32
Forum: DOS Batch Forum
Topic: Assign cmdline output to var with inner cmdline quotes?
Replies: 10
Views: 7877

Re: Assign cmdline output to var with inner cmdline quotes?

Hi T3rry, I suppose the $set is a macro, perhaps the one from SO: Assign output of a program to a variable using a MS batch file . But even then it should work with spaces, I tested it and it works for me with: call :initMacro %$set% output=""with space\calc.exe" -parm1 "https://www.foobar.com/web/p...
by jeb
22 Jun 2020 00:43
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: 4779

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

Btw. the @ has also sme impact.

Code: Select all

@echo on
cls
(
echo Start

@ ec^
ho #1: Works
@ec^
ho #2: Fails

@@^
@@ ec^
ho #3: Works

xyz@@^
@@ ec^
ho #4: Works
)

echo End
by jeb
22 Jun 2020 00:38
Forum: DOS Batch Forum
Topic: Pass multiple lines(through stdin) from batch to powershell
Replies: 4
Views: 5746

Re: Pass multiple lines(through stdin) from batch to powershell

Hi lockedscope, you found already the relevant posts on SO. Pipes (mostly) creates a child cmd.exe instance on both sides. The command itself will be executed in the child instance, but the first expansion occurs in the parent instance. The parent instance will use the percent expansion, but the del...
by jeb
22 Jun 2020 00:30
Forum: DOS Batch Forum
Topic: How batch parsing phases work?
Replies: 4
Views: 4515

Re: How batch parsing phases work?

Hi,

your first analysis is correct, but not the second one.

the line: set c=^^^!text^^^!
assigns !text! to c

Therefore the line: echo %c%

only has to expand !text! to "my"
by jeb
22 Jun 2020 00:20
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: 4779

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

Hi lockedscope, nice finding :!: I didn't knew that and never tested it. The rule seems to be: - In paremthesis: - If a caret+line feed splits the command token (usually the first token), then only the part after the last LF is used - This rule is true for any position in the parenthsis, not only th...
by jeb
16 Jun 2020 00:09
Forum: DOS Batch Forum
Topic: How batch parsing phases work?
Replies: 4
Views: 4515

Re: How batch parsing phases work?

Hi lockedscope, it's quite correct. But my first rule is: Always monitor variables unmodified :!: You can use delayed expansion for that or the SET command, but never percent expansion, that only confuses the result 8) If you add set b after the line set "b=%a%" you see that the content of <b> is "^...
by jeb
15 Jun 2020 07:17
Forum: DOS Batch Forum
Topic: Dynamic loop code over multiple lines causes extra quotes
Replies: 7
Views: 5831

Re: Dynamic loop code over multiple lines causes extra quotes

Hi lockedscope, So, how could that 10/11 carets works? The problem is, in your case there are multiple escape phases! Start: "for... "^^^^^^^^^^!text^^^^^^^^^^! ...." phase2: "for... "^^^^^!text^^^^^! ..." phase5: "for... "^^!text^^! ..." CALL doubling: "for... "^^^^!text^^^^! ..." Restart parsing p...
by jeb
13 Jun 2020 10:31
Forum: DOS Batch Forum
Topic: How delayed expansion works?
Replies: 3
Views: 3950

Re: How delayed expansion works?

Hi lockedscope,

yes your eplanation is correct.
Percent expansion is always the first one and can't be suppressed.
Then the for-variables expansion occurs.
And the last expansion can be the delayed expansion, if enabled.

jeb
by jeb
11 Jun 2020 05:27
Forum: DOS Batch Forum
Topic: Is there a way to split a string to new lines in file by delimiter
Replies: 4
Views: 6952

Re: Is there a way to split a string to new lines in file by delimiter

Hi brentonv, you link to SO Split values into separate lines for each delimiter - batch shows already a working solution :D @echo off setLocal EnableDelayedExpansion for /f "delims=" %%a in (string.txt) do ( set "line=%%a" echo reading line: !line! for /F "delims=" %%C in (""!line:^:^=^"^ "!"^") do ...
by jeb
15 May 2020 00:00
Forum: DOS Batch Forum
Topic: Debugging / syntax checksing tools for batch
Replies: 27
Views: 22361

Re: Debugging / syntax checksing tools for batch

Hi Yanta, if you don't know the line where the error occurs, you could add markers like echo Line: 123 >> debug.txt ... echo Line: 456 >> debug.txt Add these markers until you know the exactly line number. The rest should be easy. It should be possible to add the markers automatically with JREPL to ...
by jeb
11 May 2020 00:38
Forum: DOS Batch Forum
Topic: able to run functions from another script?
Replies: 4
Views: 4585

Re: able to run functions from another script?

Hi deusery, yes you can. There are different solutions to build a batch library, but no perfect one. 1) You can use a HACK/bug/feature of cmd.exe If you call a label in the same file and then start a second batch file without CALL, then the label will be jumped to also in the second batch file! batc...
by jeb
07 Apr 2020 23:09
Forum: DOS Batch Forum
Topic: can you do this batch ocrrectly for me please
Replies: 7
Views: 7118

Re: can you do this batch ocrrectly for me please

Hi, you should check, that there is no ping.bat in your working directory, else it will be infinitely repeated, because "ping 66.151.33.4 -t" will call the batch file "ping.bat" not the ping.exe command. Your other problem is the character encoding of "Conexión de red inalámbrica". You got the error...
by jeb
07 Apr 2020 05:25
Forum: DOS Batch Forum
Topic: can you do this batch ocrrectly for me please
Replies: 7
Views: 7118

Re: can you do this batch ocrrectly for me please

Hi abuchaibe3, first your problem with "ping 66.151.33.4 -t" if i dont save it as .bat with notepad, but if i do that the command doesn't stop repeating I guess, you save it as "ping.bat" ? If yes, think about it a minute and you will find the problem. Your first problem occurs probably from your ut...
by jeb
07 Apr 2020 00:00
Forum: DOS Batch Forum
Topic: Special Characters contained in Variable used in String:Replace command...
Replies: 1
Views: 2780

Re: Special Characters contained in Variable used in String:Replace command...

Hi Arianax, simple: You can't :!: It's not possible to escape an equal sign in the search string. There exist some pure batch solutions (also on Dostips), but I would recommend the easy to use and powerful solution from Dave JREPL . This is a JScript/Batch hybrid from one of our honored, expert memb...