Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,555 of 68,980    |
|    Zaidy036 to dr.j.r.stockton@gmail.com    |
|    Re: Remove all but digits    |
|    26 May 20 14:27:07    |
   
   From: Zaidy036@air.isp.spam   
      
   On 5/26/2020 12:41 PM, dr.j.r.stockton@gmail.com wrote:   
   > On Tuesday, 26 May 2020 13:46:09 UTC+1, dr.j.r...@gmail.com wrote:   
   >   
   >> So, how do I, with default privilege, write to the   
   >> environment which SET will now show?   
   >   
   > There MUST be a better way, but the following does it.   
   >   
   > MTR is MiniTrue (which I use very frequently), a lister, finder,   
   > and replacer. Here, it just finds the line containing 'SET'.   
   > The idea is to create a small batch file, presently $QQ.BAT,   
   > to do the final move. Probably, FIND or FINDSTR would serve,   
   > maybe faster; I have yet to try.   
   >   
   > $REG.BAT is merely for my own convenience in testing; the   
   > true tool is REGLARXP.BAT, which calls REGLARXP.JS and   
   > then completes the job.   
   >   
   > Obviously, $QQ.BAT ought to be in %TEMP%, but I'm not sure   
   > whether it will work there.   
   >   
   > Some tidying is still needed.   
   >   
   > Beware possible line-wrap.   
   >   
   >   
   > :: $REG.BAT - tester for REGLARXP.BAT   
   >   
   > @set ZIN=123 fff 456   
   > @set ZOUT=X   
   >   
   > @echo $REG.BAT says ZOUT is : %ZOUT%   
   >   
   > @call REGLARXP ZIN "\D+" "g" "A" ZOUT   
   >   
   > @echo $REG.BAT says ZOUT is : %ZOUT%   
   >   
   > @echo.   
   >   
   >   
   > :: REGLARXP.BAT (c) J R Stockton 2020-05-26+   
   >   
   > @echo REGLARXP.BAT says %5 = %ZOUT%   
   >   
   > @call CSCRIPT //nologo REGLARXP.JS %* | MTR -oc- SET > $QQ.BAT   
   >   
   > @call $QQ.BAT   
   >   
   > @del $QQ.BAT   
   >   
   > @echo REGLARXP.BAT says %5 = %ZOUT%   
   >   
   > @REM which seems to be true.   
   >   
   >   
   >   
   > // REGLARXP.JS (c) JRS 2020-05-26+   
   > // Arguments are : SRC Rex Mod Sub DST   
   >   
   > WScript.Echo(" REGLARXP.JS has started")   
   >   
   > WScript.Echo(" Test .replace : " + "*NO*".replace(/NO/, "YES"))   
   >   
   > var Args = WScript.Arguments   
   > WScript.Echo(' Arguments : ' + Args(0) + ', ' +   
   > Args(1) + ', ' + Args(2) + ', ' + Args(3) + ', ' + Args(4))   
   >   
   > var WshShell = new ActiveXObject("WScript.Shell")   
   > var objEnv = WshShell.Environment("Process") // was Process   
   >   
   > var Src = objEnv(Args(0))   
   > var Reg = Args(1)   
   > var Mod = Args(2)   
   > var Sub = Args(3)   
   > var Dst = Args(4)   
   > WScript.Echo(" REGLARXP.JS got Args(0) : " + Args(0) + " = " + Src)   
   > WScript.Echo(" REGLARXP.JS got Args(1) : " + Reg)   
   > WScript.Echo(" REGLARXP.JS got Args(2) : " + Mod)   
   > WScript.Echo(" REGLARXP.JS got Args(3) : " + Sub)   
   > WScript.Echo(" REGLARXP.JS got Args(4) : " + Dst + " = " + objEnv(Args(4)))   
   >   
   > var Out = Src.replace(new RegExp(Reg, Mod), Sub)   
   >   
   > WScript.Echo(" Src.replace : result is : " + Out)   
   >   
   > WScript.Echo(" Current " + Dst + " is " + objEnv(Args(4)))   
   >   
   > WScript.Echo(" Write to environment next")   
   >   
   > objEnv(Dst) = Out // Does not affect caller environment   
   >   
   > WScript.Echo(" Current " + Dst + " is " + objEnv(Args(4))) // looks OK   
   > WScript.Echo(" but set only locally\r\n \t\t\t@SET " + Dst + "=" + Out)   
   >   
   > WScript.Echo(" REGLARXP.JS finishing")   
   >   
   > // End REGLARXP.JS   
   >   
   >   
   >   
   >   
   > There MUST be a better way, not needing $QQ.BAT.   
   >   
   > --   
   > (c) John Stockton, near London, UK. Using Google Groups.   
   > Mail: J.R.""""""""@physics.org - or as Reply-To, if any.   
   >   
   SETx _VAR=rtfgh   
      
   You can use _VAR in a new batch AFTER close batch SETx was used in.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca