Another day, another bit of tinkering with some of my old Python scripts to try 
and get my head round Nim.

This is an old script I had which takes a list of [IMHO] junk processes and 
kills them on my OSX laptop. [For the purposes of testing I'm just using Finder 
and Dock as placeholders, as they'll relaunch automatically after killing, 
which speeds up testing]

Assuming execProcess is the way to go, I've come up with:
    
    
    #import
    import osproc
    
    #processes to kill
    var processes = ["Finder","Dock"]
    for process in processes:
      execProcess("pkill", args=[" -9", process])
    
    
    Run

but, when I run that I get:
    
    
    Error: expression 'execProcess("pkill", [" -9", process], nil,
                {poStdErrToStdOut, poUsePath, poEvalCommand})' is of type 
'TaintedString' and has to be discarded
    
    
    Run

"TaintedString" is a new one on me. But I'm assuming it's the usual newbie 
error when trying out a strongly typed language and I'm somehow mixing types in 
the command I'm passing to execProcess. So I tried with:
    
    
    execProcess("pkill", args=[" -9", $process])
    
    
    Run

instead. But still got the same error.

The example in the docs has the args to the command 'hard-wired':
    
    
    let outp = execProcess("nim", args=["c", "-r", "mytestfile.nim"], 
options={poUsePath})
    let outp_shell = execProcess("nim c -r mytestfile.nim")
    
    
    Run

So, how do I pass args in as a variable?

Reply via email to