I am not sure what exactly your problem is.
dtntrigger does not call your script, or it does not give the correct file to the triggered script, or the file your script gets is not existing?
At least, on the Pi (just tested) this works
$ cat test.sh #!/bin/bash
echo hallo touch /tmp/ok
$ dtntrigger ubuntu-app /bin/sh test.sh
....No wit waits indefinitely for bundles send to ubuntu-app.
Using another console, or another computer and do $ echo bla | dtnsend dtn://rpi1/ubuntu-app Transfer stdin to dtn://rpi1/ubuntu-app
results in
hallo
On the console you started dtntrigger. (and the test.sh should have the source EID as first parameter and the payload file as second. I just forgot to print it in this example)
Sebastian
Am 18.09.2013 um 12:12 schrieb Shyam B shyambs85@gmail.com:
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_help(); 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.
-- Best Regards, Shyam -- !! This message is brought to you via the `ibr-dtn' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to ibr-dtn-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/ibr-dtn.