You can do this with LGPL software, but you cannot do this with GPL licensed software.
LGPL 2.1 section 6 on combined works says how you can use the library in your closed source program.
You can call a LGPL licensed program like you do, and you can even dynamically link to it.
The GPL has no such exception, when you use a GPL program/library as part of your program, so that it is perceived as an integral part of your program, then you have to license everything under a GPL compatible license. See this GPL-FAQ entry.