Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!husc6!cmcl2!brl-adm!adm!drears@ARDEC.arpa From: drears@ARDEC.arpa (FSAC) Newsgroups: comp.unix.wizards Subject: Re: Adding to Environment Pointers Message-ID: <7950@brl-adm.ARPA> Date: Mon, 22-Jun-87 15:20:39 EDT Article-I.D.: brl-adm.7950 Posted: Mon Jun 22 15:20:39 1987 Date-Received: Tue, 23-Jun-87 04:56:45 EDT Sender: news@brl-adm.ARPA Lines: 62 I am trying to write a program that sets up a environment and then execs a shell. I am trying to build my environmental poingters one by one but when I run the compiled program I get the error message: "Trace/BPT trap". I am running ULtrik 2.0 on a VAX 8600. ANy comments would be appreciated. I have tried using the putenv(3) command put it doesn't always work right. He is the code that matters: #include #include #include #define PATH "/usr/pica/bin:/bin:/usr/ucb:/usr/usg:/usr/brl/bin:/local/bin" extern int errno; main(argc,argv,envp) int argc; char *argv[], *envp[]; { FILE *fopen(), *fp; int result; int uid, auid, agid; char *identity, username[15]; char command[300], userfile[50], *fgets(), line[15], *ret; char *home, *malloc(); char *newarg[], *newenvp[]; struct passwd *pwp, *getpwnam(), *getpwuid(); identity=argv[0]; /* rest of code is deleted for space consideration reason i get home define from the password entry */ if (chdir(home)){ fprintf(stderr,"ERRNO=%d",errno); fprintf(stderr,"%s: Could not cd to %s\n",identity,home); fprintf(stderr,"ERRNO=%d",errno); exit(-1); } /* set up the envirnoment */ newarg[0]="/bin/sh"; newenvp[0]=PATH; sprintf(newenvp[1],"HOME=%s",home); sprintf(newenvp[2],"PS1=%s>",identity); sprintf(newenvp[3],"MAIL=%s/mailbox",home); sprintf(newenvp[4],"USER=%s",identity); system("/bin/sh"); /* exec the shell with the new identity */ exect("bin/sh",newarg,newenvp); } Dennis