1753936 Members
9945 Online
108811 Solutions
New Discussion юеВ

expect and who -m

 
A. Daniel King_1
Super Advisor

expect and who -m

Hi, folks.

I'm trying out expect and having a bit of a headache. Expect 5.38.0, HP-UX 11i.

I'm using something like:

...
spawn /bin/su - joeuser
expect "Password:" { send "Big_Secret\r" }
...

But when I get to the /etc/profile, who -m does not work! Any ideas? This becomes important as who -m indicates the inital login user (regardless of su), and I've got some scripts which rely upon this for security.

who -m returns exactly nothing. Normal who works.

Thanks in advance.
Command-Line Junkie
9 REPLIES 9
S.K. Chan
Honored Contributor

Re: expect and who -m

Corrupted utmp and wtmp files maybe ? Have you tried recycled those files ? What about..
$ who am i
Does that return anything at all ?
A. Daniel King_1
Super Advisor

Re: expect and who -m

who am i also returns nothing.
Command-Line Junkie
A. Daniel King_1
Super Advisor

Re: expect and who -m

Even after nullifying wtmp, etc. no information from who am i!
Command-Line Junkie
Michael Steele_2
Honored Contributor

Re: expect and who -m

To zero out:
>/var/adm/wtmp

Right permissions?

644

If not there:

touch /var/adm/wtmp

See 'man last' or finger.

Support Fatherhood - Stop Family Law
malay boy
Trusted Contributor

Re: expect and who -m

whoami command used the /etc/utmp.May be your /etc/utmp having some problem.
I guest you can remove it and add it back.

# rm /etc/utmp
# touch /etc/utmp

make sure the permission in this file are correct.
There are three person in my team-Me ,myself and I.
Donny Jekels
Respected Contributor

Re: expect and who -m

try

set -- $(who -Rm)

als check your /etc/profile, if there is any neat tricks to kick you out if you don't come in from a regular tty or console.

I'll check this thread back later. might have a solution for you. not at the office now.
"Vision, is the art of seeing the invisible"
A. Daniel King_1
Super Advisor

Re: expect and who -m

I work around this with a variation upon:

who -mTR > /dev/null
if [ $? -ne 0 ]
then
who -mTR
else
echo make up some values
fi
Command-Line Junkie
A. Daniel King_1
Super Advisor

Re: expect and who -m

Make that -ne an -eq ...
Command-Line Junkie
Donny Jekels
Respected Contributor

Re: expect and who -m

see the attached script. it will help you out.

it has been tested and it works.
"Vision, is the art of seeing the invisible"