Created
November 17, 2016 15:59
-
-
Save fernandoc1/99cdd6f094bbcc374a96824debc8f84b to your computer and use it in GitHub Desktop.
Getting environment variable from script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/bash | |
| export RUN_FROM_SCRIPT=1 | |
| ./a.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cstdlib> | |
| #include <cstring> | |
| #include <opencv2/opencv.hpp> | |
| int main() | |
| { | |
| char* runFromScriptVar = getenv("RUN_FROM_SCRIPT"); | |
| if(runFromScriptVar) | |
| { | |
| std::cout << "OK" << std::endl; | |
| } | |
| else | |
| { | |
| system("zenity --error --text=\"Please launch from script\""); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment