Command from a string

Sounds like you are thinking of a shell command? To do that you want to spawn a shell:

julia> run(`sh -c $str`);
hello world

This is the analogue of the os.system function in Python or the system function in C.

Of course, the whole reason why Julia’s run commands are set up the way they are is to avoid spawning a shell and to avoid brittle manual escaping. See also this discussion: Better support for running external commands - #8 by stevengj

Could you give more context about why you are doing this?

2 Likes