[comp.unix.questions] Mysterious error message: scenario please

don@umd5 (Chris Sylvain) (11/21/86)

[]
I'd like to know just what could possibly be causing the following error
message in response to a call to system() with a string that if typed
by hand to a shell works just fine -- "00: is not an identifier".
I'm totally mystified, and invite wild speculation on the part of you
net.people (or comp.people if you've been renamed already) on what the cause
might be...

-- 
--==---==---==--
.. And hast thou slain the Jabberwock? ..

ARPA: don@umd5.UMD.EDU     BITNET: don%umd5@umd2
UUCP: ..!seismo!umd5.umd.edu!don

m5d@bobkat.UUCP (Mike McNally ) (11/22/86)

In article <1369@umd5> don@umd5 (Chris Sylvain) writes:
>[]
>I'd like to know just what could possibly be causing the following error
>message in response to a call to system() with a string that if typed
>by hand to a shell works just fine -- "00: is not an identifier".
>I'm totally mystified, and invite wild speculation on the part of you
>net.people (or comp.people if you've been renamed already) on what the cause
>might be...
>
>-- 
>--==---==---==--
>.. And hast thou slain the Jabberwock? ..
>
>ARPA: don@umd5.UMD.EDU     BITNET: don%umd5@umd2
>UUCP: ..!seismo!umd5.umd.edu!don

Could be that the shell you type the command into is not the same shell
used by system().  If I recall, system() uses /bin/sh.  Perhaps if you
provided more details concerning the shell command someone could be
more helpful to you.  Sort of like telling your doctor, "when I execute
a certain body function, I see a large rabbit and hear Frank Sinatra
singing; what could be wrong?"

-- 
****                                                         ****
**** At Digital Lynx, we're almost in Garland, but not quite ****
****                                                         ****

Mike McNally                                    Digital Lynx Inc.
Software (not hardware) Person                  Dallas  TX  75243
uucp: ...convex!ctvax!bobkat!m5                 (214) 238-7474

jerryp@tektools.UUCP (11/22/86)

In article <1369@umd5> don@umd5 (Chris Sylvain) writes:
> []
> I'd like to know just what could possibly be causing the following error
> message in response to a call to system() with a string that if typed
> by hand to a shell works just fine -- "00: is not an identifier".

[I've redirected followups to comp.unix.questions only.]

I haven't checked into *why* your message is happening, but I can reproduce
it.  If your environment is trashed (has an environment variable with a bad
name), you can get the message.  Here's an example from 4.3BSD... the Bourne
shell never starts:

	Script started on Sat Nov 22 05:49:49 1986
	$ /bin/csh -f
	% setenv "FOO bar" trash
	% sh
	FOO bar=trash: is not an identifier
	%

--Jerry Peek, Tektronix, Inc.
US Mail:    MS 74-900, P.O. Box 500, Beaverton, OR 97077
uucp:       {allegra,decvax,hplabs,ihnp4,ucbvax}!tektronix!tektools!jerryp
CS,ARPAnet: jerryp%tektools@tektronix.csnet
Phone:      +1 503 627-1603

don@umd5.UUCP (11/23/86)

In article <1903@tektools.UUCP> jerryp@tektools.TEK.COM (Jerry Peek) writes:
>In article <1369@umd5> don@umd5 (Chris Sylvain) writes:
>> ...
>> error message in response to a call to system()
>> -- "00: is not an identifier".
>
>I haven't checked into *why* your message is happening, but I can reproduce
>it.  If your environment is trashed (has an environment variable with a bad
>name), you can get the message.  Here's an example from 4.3BSD... the Bourne
>shell never starts:
>
>	Script started on Sat Nov 22 05:49:49 1986
>	$ /bin/csh -f
>	% setenv "FOO bar" trash
>	% sh
>	FOO bar=trash: is not an identifier
>	%

I never touched **envp, honest!
Also, "FOO bar=trash" is not the same as "00" <- read "zero,zero".
I peeked at the sh sources and can see where the "notid" error message
is generated, but I don't know why or how. For me, all it takes is a
plain-vanilla system call like system("printenv") to generate the error
message. Really mysterious.

-- 
--==---==---==--
.. And hast thou slain the Jabberwock? ..

ARPA: don@umd5.UMD.EDU     BITNET: don%umd5@umd2
UUCP: ..!seismo!umd5.umd.edu!don

levy@ttrdc.UUCP (11/23/86)

In article <1369@umd5>, don@umd5 (Chris Sylvain) writes:
>[]
>I'd like to know just what could possibly be causing the following error
>message in response to a call to system() with a string that if typed
>by hand to a shell works just fine -- "00: is not an identifier".
>I'm totally mystified, and invite wild speculation on the part of you
>net.people (or comp.people if you've been renamed already) on what the cause
>might be...

My speculation: garbage being somehow put in the environment.  An example:

main()
{
	putenv("00");
	system("echo hello world");
}

$ a.out
00: is not an identifier
-- 
 -------------------------------    Disclaimer:  The views contained herein are
|       dan levy | yvel nad      |  my own and are not at all those of my em-
|         an engihacker @        |  ployer or the administrator of any computer
| at&t computer systems division |  upon which I may hack.
|        skokie, illinois        |
 --------------------------------   Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa,
	   go for it!  			allegra,ulysses,vax135}!ttrdc!levy

mouse@mcgill-vision.UUCP (11/24/86)

In article <1369@umd5>, don@umd5 (Chris Sylvain) writes:
> I'd like to know just what could possibly be causing the following error
> message in response to a call to system() with a string that if typed
> by hand to a shell works just fine -- "00: is not an identifier".

As you have probably already been informed, this is because the Bourne
shell, which is the shell system() uses, doesn't like environment
entries not conforming to a specific syntax.

[This is a BUG, do you hear me, a BUG....]

Might I suggest a patch to sh (line numbers are 4.3BSD version, but
this should work on the 4.2 version if you adjust the line numbers):

	diff -c -r sh/name.c /usr/src/bin/sh/name.c
	*** sh/name.c	Sun Nov 23 22:28:13 1986
	--- /usr/src/bin/sh/name.c	Sun Nov 10 18:32:05 1985
	***************
	*** 55,61 ****
	  {
	  	WHILE arg
	  	DO REG STRING	s=mactrim(arg->argval);
	! 	   setname(s, xp, 0);
	  	   arg=arg->argnxt;
	  	   IF flags&execpr
	  	   THEN prs(s);
	--- 55,61 ----
	  {
	  	WHILE arg
	  	DO REG STRING	s=mactrim(arg->argval);
	! 	   setname(s, xp);
	  	   arg=arg->argnxt;
	  	   IF flags&execpr
	  	   THEN prs(s);
	***************
	*** 64,73 ****
	  	OD
	  }
	  
	! VOID	setname(argi, xp, nofail)
	  	STRING		argi;
	  	INT		xp;
	- int nofail;
	  {
	  	REG STRING	argscan=argi;
	  	REG NAMPTR	n;
	--- 64,72 ----
	  	OD
	  }
	  
	! VOID	setname(argi, xp)
	  	STRING		argi;
	  	INT		xp;
	  {
	  	REG STRING	argscan=argi;
	  	REG NAMPTR	n;
	***************
	*** 98,107 ****
	  			return;
	  		FI
	  	FI
	!  if (nofail)
	!   { return;
	!   }
	!  failed(argi,notid);
	  }
	  
	  replace(a, v)
	--- 97,103 ----
	  			return;
	  		FI
	  	FI
	! 	failed(argi,notid);
	  }
	  
	  replace(a, v)
	***************
	*** 306,312 ****
	  	REG STRING	*e=environ;
	  
	  	WHILE *e
	! 	DO setname(*e++, N_ENVNAM, 1) OD
	  }
	  
	  LOCAL INT	namec;
	--- 302,308 ----
	  	REG STRING	*e=environ;
	  
	  	WHILE *e
	! 	DO setname(*e++, N_ENVNAM) OD
	  }
	  
	  LOCAL INT	namec;

					der Mouse

USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse
     think!mosart!mcgill-vision!mouse
Europe: mcvax!decvax!utcsri!mcgill-vision!mouse
ARPAnet: think!mosart!mcgill-vision!mouse@harvard.harvard.edu

[USA NSA food: terrorist, cryptography, DES, drugs, CIA, secret, decode]

henry@utzoo.UUCP (Henry Spencer) (11/25/86)

As I recall, the "is not an identifier" message means that the shell
found an environment string which was not in the "variable=value" form
that pre-V8 shells insist on.  This means either somebody has mangled
the environment, or else dear old init isn't setting up a proper
environment before forking children and a shell is eventually getting
run without any of its ancestors doing anything about an environment.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry

jsdy@hadron.UUCP (Joseph S. D. Yao) (12/12/86)

In article <1369@umd5> don@umd5 (Chris Sylvain) writes:
>message in response to a call to system() with a string that if typed
>by hand to a shell works just fine -- "00: is not an identifier".

Got the same message by using Bell's scheme for logging into a
chroot'ed shell in System V.  In that case, the environment var
list was trashed to put a funny SUB-LOGIN symbol.  The Bourne
shell saw this, and had fits.

System() also uses the Bourne shell, perforce (unless you've
modified it the way I did mine).  Somehow, you're getting a
weird environment string in that says "00" something.  You
may be trashing your stack.
-- 

	Joe Yao		hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}
			jsdy@hadron.COM (not yet domainised)