How to call the Nsh command in a custom application

How to call the Nsh command in a custom application, just as in the windows call cmd command,
such as:
system(“fun.exe”)

The mavlink shell does this. You should be able to use an instance of MavlinkShell (https://github.com/PX4/Firmware/blob/f67e44215ff5178d507bb817eee66b469a93c5e3/src/modules/mavlink/mavlink_shell.cpp) in your application. The MavlinkShell class itself does not have anything to do with mavlink, it’s just a class that allows you to interact with a nuttx shell via C++.

The current NuttX code also supports the standard system function. The only thing that is non-standard about the system() function is that it invokes NSH not /bin/sh.

So you can do just what you want to do using just the code snippet that you gave as an example.

The system function is not available if you are using the is you are using an old version of NuttX.

Greg