Solved! Is it possible to run an external cmd in background?
run(`sleep 10`)
works, but not
run(`sleep 10 \&`)
In my docu run() is shown as
run(command, args…)
Run a command object, constructed with backticks. Throws an error if anything goes wrong, including the process exiting with a non-zero status.
How to use the comma separated syntax?
cmd = `kill`
run(cmd,12452 5467)
does not work.
Solved! How to pass arguments correct over?
If I like to stop several processes
run(`kill 12452 5467`)
works fine. But if I generate a string of pids and try
string = “12452 5467”
run(`kill $string`)
is not working. Although if I pass Integers over
s1 = 12452
s2 = 5467
run(`kill $s1 $s2`)
it works. So how create an object which contains several integers and is accepted as argument?
Ah, try a tuple
stuple = tuple(12452,5467)
this works.
Solved! If an external cmd fails and exit with error code 1 is
try
run()
catch
the only possibility to react on it? Or how else? Or how can I get back an empty string result?
Thx for any hints. Your help is very welcome as always.
In Julia 0.6 it is spelled spawn(`sleep 10`). You can wait on the result with wait if you want. You can also run commands in asynchronous tasks (green threads) with @async. Julia has good support for asynchronous I/O of all kinds.
The older blog post Put This In Your Pipe is still helpful though some of the syntax has changed slightly and Shelling Out Sucks is good to read for the for rationale behind Julia’s approach.