Dear Johannes/*Stephan*,
Thank you for the reply to my post. The code had a type '&', which I did not intend to run in background :) The ::system() call works (as I see in eclipse), the 'complete script path' did the trick, however, the DTNTRIGGER.exe does not work still work. I wonder, where I am going wrong.
Updated code: --------------------- #include <csignal> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h>
//#include "/home/s116793/Dropbox/AmazingCode/ScriptTest/dtncode/ibrdtn-0.10.1/ibrdtn/data/Bundle.h" #include <ibrdtn/data/Bundle.h>
#include <iostream> using namespace std;
// std::string _appname = "trigger"; std::string _script = "/home/s116793/bashscript.sh"; std::string _shell = "/bin/sh";
int main() { cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!! // call the script std::string cmd = _shell + " " + _script + " " + "NodeA" + " " + "/home/s116793/something"; cout << "The cmd is:"<<cmd<<endl; ::system(cmd.c_str());; return 0; }
OUTPUT: -------------- !!!Hello World!!! The cmd is:/bin/sh /home/s116793/bashscript.sh NodeA /home/s116793/something Hello guys.. Number of arguments 1 arguments Argument list: ['/home/s116793/triggered.py'] Name of the file /home/s116793/text.txt
------------------- I did try what you suggested, giving an app-name for the dtntrigger: the command at the receiver: dtntrigger ubuntu-app /bin/sh /home/s116793/bashscript.sh
No file is created!
Another thing to notice: -------------------------------- When I look into the cpp code also, we have set an app_name = "trigger" which is overwritten in the switch case.
ONE minor correction: // print help if not enough parameters are set 125 if (optindex < 2) { print_helphttp://www.ibr.cs.tu-bs.de/projects/ibr-dtn/doxygen/0.10.0/dtnconvert_8cpp.html#a853216ac51aa181669ff4d3de74058a7(); exit(0); }
This should be "optindex <= 2", forcing the user to enter three command line arguments. Entering two arguments with dtntrigger call, sets the _appname and _shell and setting _script is left out.