[Tutor] Using popen

Sheila King sheila@thinkspot.net
Sun, 7 Apr 2002 01:13:34 -0800


On Wed, 3 Apr 2002 12:25:28 -0800 (PST), Danny Yoo wrote:

> So the value that the close() returns is actually a combination of
> the "exit status" that we're looking for, along with a "signal"
> number.  And to get the true exit status, we'll want to grab the
> high byte.  One way to do this is to just push the signal number
> part right off by using bitwise right shifting:
>
> ###
> > > > 256 >> 8
> 1 ###
>
> That is, just shift the number by 8 bits.  What's left is the
> return value that we're looking for.  (By the way, this bit shift
> is equivalent to what Sean was doing with the modulo 255
> arithmetic.)

>
> You're actually getting an exit code of 1, so your program may be
> signalling an error of some sort.

I just wanted to follow up and say, that I finally figured out what 
my problem was, and why I was getting an exit code of 1.

I needed to include a trailing "newline" character on the password, 
and I was omitting it. Thus, the error code. Now that I'm including 
the trailing newline character, it is working fine.

(Reading the docs carefully always helps!!!)

-- 
Sheila King
http://www.thinkspot.net/sheila/