In Windows shell scripting (cmd.exe) how do you assign the stdout of a program to an environment variable?
Tag : python , By : Joshua Johnson
Date : March 29 2020, 07:55 AM
will be helpful for those in need In UNIX you can assign the output of a script to an environment variable using the technique explained here - but what is the Windows equivalent? , Use: for /f "delims=" %A in ('<insert command here>') do @set <variable name>=%A
for /f "delims=" %A in ('time /t') do @set my_env_var=%A
|
Scripting environment setup in windows
Date : March 29 2020, 07:55 AM
hop of those help? It is pretty straight-forward to put all of that in a bat file, something like this: @echo off
rmdir /S /Q testdir
rmdir /S /Q workdir
start cmd /K c:\foo\bar.bat
start cmd /K c:\foo\bas.bat
start firefox.exe "http://www.stackoverflow.com/"
|
how to check whether dos environment property is set or not in ant scripting
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Ant script , The following is the "ANT way" to conditionally set properties. <project name="test" default="run">
<property environment="env"/>
<target name="check-prop" unless="${env.PARA}">
<property name="env.PARA" value="abc"/>
</target>
<target name="run" depends="check-prop">
<echo message="${env.PARA}"/>
</target>
</project>
$ ant
Buildfile: /home/mark/tmp/build.xml
check-prop:
run:
[echo] abc
BUILD SUCCESSFUL
$ (export PARA="hello world"; ant)
Buildfile: /home/mark/tmp/build.xml
check-prop:
run:
[echo] hello world
BUILD SUCCESSFUL
|
F# environment integration (for scripting)
Tag : .net , By : Jim Davis
Date : March 29 2020, 07:55 AM
To fix this issue You want to use the System.Management.Automation namespace. Here's an example of running some cmdlets from F#. // C:\Program Files (x86)\Reference Assemblies\Microsoft\WindowsPowerShell\3.0
open System.Management.Automation
open System.Management.Automation.Runspaces;
let runSpace = RunspaceFactory.CreateRunspace()
runSpace.Open()
let pipeline = runSpace.CreatePipeline()
let getProcess = new Command("Get-Process")
pipeline.Commands.Add(getProcess)
let sort = new Command("Sort-Object")
sort.Parameters.Add("Property", "VM")
pipeline.Commands.Add(sort)
// Identical to the following PowerShell command line:
// PS > Get-Process | Sort-Object -Property VM | select ProcessName
let output = pipeline.Invoke()
for psObject in output do
psObject.Properties.Item("ProcessName").Value.ToString()
|> printfn "%s"
|
OBJ-C Scripting Bridge - Trouble creating scripting object with properties (Microsoft Word)
Date : March 29 2020, 07:55 AM
Hope that helps SB doesn't work properly; never has, never will. It's particularly prone to compatibility problems with Carbon-based apps like Word which have greater variability in how they construct references and commands, though even Cocoa apps will give it gyp. Here is how you do it in AppleScript, where it works perfectly: tell application "Microsoft Word"
make new auto text entry at attached template of active document ¬
with properties {name:"test name", auto text value:"test value"}
end tell
[theWordTemplate addObject:theNewAutoTextEntry];
|