A similar question has been asked here before but it’s not clear if it was ever resolved. I followed some of the information there but couldn’t get it to work.
I’ve written my own command-line tool and would like to know how I can run it from another app.
I created a system, defined my own command and my tool runs as expected from a terminal.
My end goal here is to be able to invoke my command-line tool remotely via SMS.
The apps are running unsandboxed for the moment to make things easier.
Here’s what I’ve added to the .adef for the app wanting to run my tool.
Within the app ‘runner’ I’ve tried using popen("mytool -h", "r") but the command always returns not found.
I’ve also tried including paths before the command, I.E., "/usr/bin/mytool -h" without any success.
Worth noting that I’ve been able to run the command-line tool process/component by another process/component, but only if the executables are part of the same application. This is my fall-back solution.
I think it’s probably possible to invoke the command line program from within another app, but there is probably a better option. What I would do is structure the command line app in two components:
The core implementation of the features of the command line app
command line argument processing, passing the data to the lower level component and printing the results.
This way you can bind your app directly to the low level component and call functions rather than trying to call a command line program and parse the string output.
My motivation for re-using the CLI app was to take advantage of the Command Line Arguments API and use the same syntax for SMS commands. Responses would be redirected according to source of the command.
Reading through the api docs it seems like I might be able to do this by creating a pseudo-main which could serve as the command argument processor by using le_arg_SetArgs. I would then build up the arg array and pass that to my “main”. Unfortunately, I get a build error “undefined reference to `le_arg_SetArgs’”
Is there a library, header file (besides legato.h) or something I need to bind?
hi,
Any one can share a sample program how to pass a user defined command in terminal and get the response in terminal. How to make terminal to read command and process based on the commands when i use le_arg_scan(). my application stopped