I was writing a shell on which i am calling a c function where i exports a variable. In below example
my_test.c
int main()
{
setenv("MY_NAME","kk_rathor",1);
// get and print MY_NAME works here
}
my_test_Sh.sh
#!bin/sh
test
echo $MY_NAME // does not works here
I am getting not getting my name on printing $MY_NAME However if i am exporting anything in shell i can get it on test.c.
Is the scope of variable exported from test.c is only in that function only. if not then what am i doing wrong ?
Thanks Please let me know if the question is not clear.