send mail when code/run is finished

I am using c++ for my PhD project and I let it run on a unix server, which takes up to several days. Until now, I always have to check weather it is finished or not by login and check the output file.

Is it possible to let the code send me an email once it is done/at the end of the programe?
In MATLAB this is possible with the following line at the end of your code:
!pwd | mail -s finished NAME@GMAIL.COM

Does something like this exist in c++? I could not find anything useful in one of the existing threads about sending emails.

Thanks for your help!
It is certainly possible to do, but I think you may find an easier solution is to run your code with a shell script; something like:

1
2
3
4
#!/bin/bash

./executableName
pwd | mail -s finished NAME@GMAIL.COM


You'll note that this is identical to what your MATLAB command does; asks the existing mail programme to handle mailing for you.
Last edited on
Thanks a lot!

I am actually using shell scripts, so that is an easy way!
Topic archived. No new replies allowed.