Why Ubuntu 16.04 C++ program cannot programatically stop mono-service?
Karl Auer
kauer at biplane.com.au
Tue May 17 15:46:40 UTC 2016
Oh for goodness' sake.
Create shell.cpp:
#include <stdlib.h>
int main (int argc, char *argv[]) {
system(argv[1]);
return 0;
}
Create a script called script.sh:
#!/bin/sh
ls
Compile shell.cpp into a program called shell:
c++ shell.cpp -o shell
Run the new program with a complete shell command, including
redirection (note the double quotes!):
./shell "./script.sh > /tmp/out.txt"
... and you will see the output from the script in a file in /tmp,
after the script has been run by the C++ program.
On Tue, 2016-05-17 at 10:26 -0400, Frank Chang wrote:
> However, my
> manager wants me to write a C++ program to start the C# executable,
> Audio_Recorder.exe, as a service
Why? There is no need to write extra programs. Linux has at least four
built-in ways to do EXACTLY what you want, and all of them have been
described to you. You have also been given several profitable lines of
enquiry via google searches.
There are also numerous systems/programs for running things as services
and logging their output. Check out supervisor, for example:
http://supervisord.org
Writing your own program to do it is a total waste of time unless done
as an educational exercise.
This mailing list is about Ubuntu. It is not about writing C++. Please
find a C++ forum to help you with your programming problems.
Regards, K.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389
GPG fingerprint: E00D 64ED 9C6A 8605 21E0 0ED0 EE64 2BEE CBCB C38B
Old fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4
More information about the ubuntu-users
mailing list