I would like to reference a variable that I have in a bash script "value" as well as "max." As of now, I have a t开发者_如何学Cext interface in which after given commands, the terminal window displays something similar to
==========================================================================> 100%
for a progress bar. The variable is referenced throughout the script, and I would like to call that variable in my cocoa app.
Thanks in advance!
Your question isn't entirely clear, but it sounds like you want to use environment variables. In bash, you need to use the export
builtin to mark a variable to be exported to child processes. Then, in your Cocoa app, you can use getenv(3)
function to retrieve the environment variable value. For example:
# In your bash script
value=foo
max=bar
export value max
// Now in your Cocoa application:
char *value;
if((value = getenv("value")))
{
// Use value
}
// else value is not in the environment
精彩评论