Search found 120 matches

by jfl
12 Feb 2019 04:14
Forum: DOS Batch Forum
Topic: findstr /C:""" file.txt&&set found=1 FAILS
Replies: 6
Views: 1902

Re: findstr /C:""" file.txt&&set found=1 FAILS

You have an odd number of quotes in your request. So everything that follows the third one is passed to findstr as a single argument. To fix that, you have to ^escape one of the quotes, so that cmd.exe parses it as a normal character: C:\JFL\Temp>C:\JFL\Temp>findstr /C:^""" file.txt Some more text w...
by jfl
11 Feb 2019 06:04
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 4477

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

jeb wrote:
11 Feb 2019 05:19
BUT the scanner is able to set the new file position to the wrong position after a label is found :!:
Here, it seems that the line scanner simply assumes that a line cannot be longer than 512 bytes.
And whatever follows is just another line.
by jfl
11 Feb 2019 05:45
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 4477

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

@jeb and @dbenham: Bravo, you've progressed beyond my wildest dreams, while I was busy on other things. The magic of the Internet :D the scanner is able to set the new file position to the wrong position after a label is found :!: Yes, that's actually the initial failure mode I had, with a call endi...
by jfl
06 Feb 2019 10:15
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 4477

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

Hi, I had a crazy problem this morning after doing a minor fix of my AutoRun.cmd script for XP. The fix was working fine. Before committing the updated version, I added a comment in the file header. One last test running 'AutoRun -l' and... BOOM :x Of course, I first thought that AutoRun.cmd itself ...
by jfl
06 Feb 2019 03:18
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 2867

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

An interesting application of previous work on this forum: Create a file called "%ALLUSERSPROFILE%\AutoRun.cmd.d\pid.bat", containing: @echo off call :getPID PID exit /b :getPID [RtnVar] :: :: Store the Process ID (PID) of the currently running script in environment variable RtnVar. :: If called wit...
by jfl
05 Feb 2019 16:18
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 2867

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

@jeb I had severe difficulties distinguishing "normal" cmd.exe invokations from for /f invokations. First, on my system, in the normal case, CMDCMDLINE does not just contain "C:\Windows\system32\cmd.exe". Sometimes it is: set "CMDCMDLINE="C:\WINDOWS\system32\cmd.exe" " (Notice the additional quotes ...
by jfl
05 Feb 2019 08:24
Forum: DOS Batch Forum
Topic: Bget - A package Manager for Windows scripts.
Replies: 4
Views: 1612

Re: Bget - A package Manager for Windows scripts.

Hi jahwi, I tried your bget package manager last month, and found it very interesting. Since then I've been working on a way to manage multiple independent AutoRun files, that create batch variables and macros for all new cmd.exe windows. This management is done by an AutoRun.cmd script. I thought t...
by jfl
05 Feb 2019 08:04
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 2867

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

Finally, I've rewritten a new script from scratch: AutoRun.cmd Its features are: Manage multiple independent AutoRun scripts, that all run when a new cmd.exe window starts. Define Unix-compatible installation variables. To install AutoRun.cmd, copy it to your favorite cmd scripts directory (A direct...
by jfl
29 Jan 2019 04:15
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 2867

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

Thanks @siberia-man and @jeb for your insights. I'll try building something based on siberia-man's code, which looks real close to what I had in mind, and making sure to apply all jeb's suggestions. Basically, my idea is to minimize the amount of code in the main AutoRun.cmd script: It'd define a nu...
by jfl
26 Jan 2019 11:32
Forum: DOS Batch Forum
Topic: Is there any standard equivalent of a .bashrc script for cmd?
Replies: 10
Views: 2867

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

... And if not, could we work together to propose something common? Basically, by agreeing on common conventions, we could all do our favorite tricks without risking to step on each other's feet. This thought came from the study of possible solutions to the doskey /history issue. The problem is to a...
by jfl
26 Jan 2019 11:13
Forum: DOS Batch Forum
Topic: doskey output can't always be captured
Replies: 3
Views: 1102

Re: doskey output can't always be captured

Thanks sst, this explains everything indeed. Although it's completely logical, it's definitely a usability bug in my opinion. :evil: Anyway, the solution using a macro is simple: C:\Temp>doskey history=doskey /history $* C:\Temp>doskey /macros history=doskey /history $* C:\Temp>history | findstr dos...
by jfl
25 Jan 2019 12:24
Forum: DOS Batch Forum
Topic: doskey output can't always be captured
Replies: 3
Views: 1102

doskey output can't always be captured

Completely unrelated to my other recent posts, I noticed something very strange with doskey today: I occasionally search commands in the command history by typing something like: doskey /history | findstring SOMEPROGRAM As I'm lazy, to have less typing to do, I created a script called history.bat, t...
by jfl
25 Jan 2019 12:04
Forum: DOS Batch Forum
Topic: How to enumerate used and free file handles
Replies: 3
Views: 917

Re: How to enumerate used and free file handles

I must have been tired yesterday evening, because the code I posted if the initial post contained a bug: A last-minute change broke the elimination of known used handles. I've just fixed it in the initial post, by changing 'if %%h lss firstFreeHandle' to 'if %%h lss !firstFreeHandle!'. While at it, ...
by jfl
25 Jan 2019 11:39
Forum: DOS Batch Forum
Topic: Directly reading from pipe by the parent CMD process
Replies: 19
Views: 4217

Re: Directly reading from pipe by the parent CMD process

Here's an updated version of my :CreatePipe test script, with the following changes: Added an argument to :CreatePipe to avoid using a global variable for known handles. Rewrote :EnumHandles for better reliability. For explanations, see this post . Added several new testing options, and a help scree...
by jfl
24 Jan 2019 16:24
Forum: DOS Batch Forum
Topic: How to enumerate used and free file handles
Replies: 3
Views: 917

Re: How to enumerate used and free file handles

Aacini wrote:
24 Jan 2019 14:05
I enjoyed your description a lot! :D
...
Thank :D