Shell Script with environment variable
I have a C program that has the following code at the end:
memcpy(buff,"TEST=",4)
putenv(buff)
system("/bin/bash")
I put a new environment variable in a new shell. I want to then echo test
into a text file which i can easily do. I then want to exit the shell and
run it again so running this would look as follows
./cprog "some arg"
echo $TEST > test.txt
exit
./cprog "some arg"
echo $TEST > test.txt
exit
I have to keep exiting so I can change the TEST variable. How could I make
this work in a shell script so i could just keep looping and running the c
program so I could change the argument but never exiting the shell script
itself.
No comments:
Post a Comment