环境变量 - 父进程--- TIA [英] Environment Variable - Parent Process --- TIA
问题描述
在UNIX中将环境变量推送到父shell是否完全不可能?我想做这样的事情:
main(int argc,char * argv [])
{
char * var;
var =(char *)malloc(1028);
strcpy(var," VAR =");
strcat(var,argv [1]);
putenv(var);
return(0);
}
以上我刚刚做了,所以它可能不是很完美,但它会让b / b
得到这个想法。现在一旦退出,我想在我的环境中看到这个
变量。这可能吗?
谢谢
Is it completely impossible in UNIX to push an environment variable to
the parent shell? I would like to do something like this:
main(int argc, char *argv[])
{
char *var;
var = (char *)malloc(1028);
strcpy(var, "VAR=");
strcat(var, argv[1]);
putenv(var);
return(0);
}
The above I just did now on the fly so it may not be perfect but it
will get the idea across. Now once this exits, I want to see this
variable in my environment. Is this possible?
Thank you
推荐答案
Jimmy Cracker写道:
Jimmy Cracker wrote:
在UNIX中将环境变量
推送到父shell是否完全不可能?我想做这样的事情:
main(int argc,char * argv [])
{
char * var;
var =(char * )malloc(1028);
strcpy(var," VAR =");
strcat(var,argv [1]);
putenv( var);
返回(0);
}
以上我刚刚做了,所以它可能不完美但是它会得到这个想法跨越。现在一旦退出,我想在我的环境中看到这个变量。这可能吗?
谢谢你
Is it completely impossible in UNIX to push an environment variable to the parent shell? I would like to do something like this:
main(int argc, char *argv[])
{
char *var;
var = (char *)malloc(1028);
strcpy(var, "VAR=");
strcat(var, argv[1]);
putenv(var);
return(0);
}
The above I just did now on the fly so it may not be perfect but it
will get the idea across. Now once this exits, I want to see this
variable in my environment. Is this possible?
Thank you
小心,你要从clc'的崇拜者执行者Keith那里得到它br />
汤普森。
Watch out, you''re going to get it from clc''s wannabe enforcer Keith
Thompson.
Jimmy Cracker写道:
Jimmy Cracker wrote:
在UNIX中完全不可能推动环境变量为父shell?我想做这样的事情:
main(int argc,char * argv [])
{
char * var;
var =(char * )malloc(1028);
strcpy(var," VAR =");
strcat(var,argv [1]);
putenv( var);
返回(0);
}
以上我刚刚做了,所以它可能不完美但是它会得到这个想法跨越。现在一旦退出,我想在我的环境中看到这个变量。这可能吗?
Is it completely impossible in UNIX to push an environment variable to
the parent shell? I would like to do something like this:
main(int argc, char *argv[])
{
char *var;
var = (char *)malloc(1028);
strcpy(var, "VAR=");
strcat(var, argv[1]);
putenv(var);
return(0);
}
The above I just did now on the fly so it may not be perfect but it
will get the idea across. Now once this exits, I want to see this
variable in my environment. Is this possible?
这更像是一个Unix问题。 C对shell没什么了解
和环境变量。
试试comp.unix.programmer
干杯
Michael
-
电子邮箱:我的是/ at / gmx / dot / de地址。
This is more of a Unix question. C does not know anything about shells
and environment variables.
Try comp.unix.programmer
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
TTroy写道:
Jimmy Cracker写道:
Jimmy Cracker wrote:
在UNIX中完全不可能将环境变量推送到
父shell?我想做这样的事情:[...]
Is it completely impossible in UNIX to push an environment variable to
the parent shell? I would like to do something like this: [...]
小心,你要从clc'的崇拜者执行者Keith那里得到它
Thompson 。
Watch out, you''re going to get it from clc''s wannabe enforcer Keith
Thompson.
不,不:轮到我了!让我来! Meee!
Jimmy C的快速测验:
以下程序的输出是什么?
#include< stdio.h>
#include< string.h>
static void test(const char * p,const char * q){<
printf("%s%c =%s \ n",
p,strcmp(p,q)?''!''':''='', q);
}
int main(无效){
test(" C"," UNIX");
test(" comp.lang.c"," comp.unix.programmer");
printf(" Off-topic:");
test(你问什么,可能);
返回0;
}
答案和建议,所有这些都在一个整洁的小包装中。
-
Eric Sosman
es ***** @ acm-dot-org.inva 盖子
No, no: My turn! Let me! Meee!
A quick quiz for Jimmy C.: What is the output of the
following program?
#include <stdio.h>
#include <string.h>
static void test(const char *p, const char *q) {
printf ("%s %c= %s\n",
p, strcmp(p, q) ? ''!'' : ''='', q);
}
int main(void) {
test ("C", "UNIX");
test ("comp.lang.c", "comp.unix.programmer");
printf ("Off-topic: ");
test ("What you ask", "possible");
return 0;
}
Answer and advice, all in one neat little package.
--
Eric Sosman
es*****@acm-dot-org.invalid
这篇关于环境变量 - 父进程--- TIA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!