Skip to content

Instantly share code, notes, and snippets.

@fernandoc1
Created November 17, 2016 15:59
Show Gist options
  • Select an option

  • Save fernandoc1/99cdd6f094bbcc374a96824debc8f84b to your computer and use it in GitHub Desktop.

Select an option

Save fernandoc1/99cdd6f094bbcc374a96824debc8f84b to your computer and use it in GitHub Desktop.
Getting environment variable from script
#! /bin/bash
export RUN_FROM_SCRIPT=1
./a.out
#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