Search found 899 matches

by jeb
06 May 2019 10:49
Forum: DOS Batch Forum
Topic: Successfully escape a token delimiter in a fully qualified command path!
Replies: 6
Views: 160

Re: Successfully escape a token delimiter in a fully qualified command path!

I tested the behaviour described by Dave. c:\temp\with^ space.bat - WORKS \temp\with^ space.bat - FAILS with^ space.bat - FAILS But only when you try it from the command line :!: Tested in a batch file the results are different c:\temp\with^ space.bat - WORKS \temp\with^ space.bat - WORKS with^ spac...
by jeb
06 May 2019 00:19
Forum: DOS Batch Forum
Topic: Successfully escape a token delimiter in a fully qualified command path!
Replies: 6
Views: 160

Re: Successfully escape a token delimiter in a fully qualified command path!

Hi Dave, yes, in phase 2 the command token and the parameters are determined, therefore the escaping plays a role. but not for the splitting of the parameters (perhaps in pahse7 ?) It's also important for the delayed expansion phase, as this phase is executed indipendent for the command and the para...
by jeb
15 Apr 2019 01:18
Forum: DOS Batch Forum
Topic: how to preserve leading spaces in parameter during function call
Replies: 4
Views: 221

Re: how to preserve leading spaces in parameter during function call

There are two fundamental differnt ways to handle function parameters 1) Use a parameter ByValue, like you do in CALL :myFunc %str% This technic is simple but has also some limitations with special characters like quotes, spaces and carets. You should at least quote the content to presever spaces an...
by jeb
06 Apr 2019 05:40
Forum: DOS Batch Forum
Topic: string as statement
Replies: 4
Views: 257

Re: string as statement

This lines executes like set str1=set s1=hi cat & echo %s1% set str1=set s1=hi cat echo %s1% --- s1 doesn't contain anythig here, therefore "ECHO IS OFF" will be printed It's always a good idea to use some debugging technics (not only within batch files). View the variables, with `SET` or delayed ex...
by jeb
05 Apr 2019 06:49
Forum: DOS Batch Forum
Topic: how to make an array by function and by local variable of the function
Replies: 5
Views: 327

Re: how to make an array by function and by local variable of the function

You need to preserve the values in the ENDLOCAL-Block. @echo off set /a n=99 set ret= call :test3 ret echo show array: echo %ret.Array[0]% echo %ret.Array[1]% echo %ret.Array[2]% echo %ret.Array[3]% goto :eof :test3 setlocal EnableDelayedExpansion set /a n=0 for /L %%n in (0 1 3) DO ( set "%~1.Array...
by jeb
14 Mar 2019 05:22
Forum: DOS Batch Forum
Topic: Lag methodology
Replies: 9
Views: 664

Re: Lag methodology

Hi SIMMS7400, I would convert the date to julian date (number of days). Then use some math to add/subtract days and convert it back from the julian format to gregorian date. Look here :date2jdate - converts a gregorian calender date to julian day format :jdate2date - converts julian days to gregoria...
by jeb
11 Feb 2019 05:19
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 984

Re: Call and goto may fail when the batch file has Unix line endings

One more observation. As you already said, the scan for labels is reset at the file beginning or after a CR/LF. The label scanner reads chunks of ~512 bytes, therefore we see the described effect. BUT the scanner is able to set the new file position to the wrong position after a label is found :!: @...
by jeb
11 Feb 2019 04:49
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 984

Re: Call and goto may fail when the batch file has Unix line endings

Thanks Dave, your findings are impressive :D. I didn't see the idea of relative counting the characters :( I played with a file with unix style endings and a single CR/LF and thought the problem was gone as I didn't see the reset behaviour. But your analysis is really good. And your rule is really s...
by jeb
09 Feb 2019 12:47
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 984

Re: Call and goto may fail when the batch file has Unix line endings

Hi jfl, like Dave I'm very interessted. And I simplified your code to a minimal, failing example: @echo off goto :zwei :####################################################################################################################################################################################...
by jeb
06 Feb 2019 09:29
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 650

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi jfl, nice work! Eventually I found a heuristic that seems to give good results: - If the first token is == %COMSPEC% without quotes, then this is a for /f, and I should not run AutoRun scripts. - If the second token is /c, then this a manual execution of a single command, and it's not worth runni...
by jeb
05 Feb 2019 02:24
Forum: DOS Batch Forum
Topic: I need to escape pipe character in a string but still remove leading and trailing quotes
Replies: 6
Views: 362

Re: I need to escape pipe character in a string but still remove leading and trailing quotes

Hi bosekamineni, you should use delayed expansion, because it's always safe to expand with delayed expansion. @echo off setlocal EnableDelayedExpansion set "_string=Test String With | &&<> command" echo the string is !_string! The only drawback is that you be careful with literal exclamation marks, ...
by jeb
28 Jan 2019 03:01
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 650

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi siberia-man, - It is reliable to detect an invocation from FOR/F. - Invokations from pipes doesn't trigger the autostart at all. - When a new instance of cmd.exe is launched directly it can fail, as it's possible to add any possible parameter, but then it only drops the additional commands. It sh...
by jeb
28 Jan 2019 01:48
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 650

Re: Is there any standard equivalent of a .bashrc script for cmd?

Hi, I'm using the registry key to start a batch file, that adds some doskey macros. BUT it's a bit tricky, as the batch file will also be called for new cmd instances inovked by FOR /F :!: If the batch file doesn't check that, you can get really strange behaviour in all of your batch files. Think of...
by jeb
25 Jan 2019 13:45
Forum: DOS Batch Forum
Topic: doskey output can't always be captured
Replies: 3
Views: 323

Re: doskey output can't always be captured

Hi jfl, interesting :) I tried to build a simple workaround history.bat @echo off doskey /history | findstr /n "^" It works as expected 1:doskey /history 2:echo test 3:npp hist.bat 4:hist .. and I thought that the output of the findstr should work normal, but ... history.bat | more Still outputs not...
by jeb
21 Dec 2018 08:31
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 1503

Re: Directly reading from pipe by the parent CMD process

Hi Dave, I tested your code Windows 7 x64: 4096 Windows XP x32: 4096, but FINDSTR doesn't work reliable And I retested the blocking limit of pipe blocks. First a testString of the configured size is send. The a "second line" is send. If the blocking is active the second line is send only when thread...