You are not logged in.
Hi,
I use netcfg and am writing a script I want to run every time the network is up (POST_UP thing in netcfg). The thing is I need the list of logged in users at that time.
I thought `w` and some string processing would do the trick but here is what I get:
$ w
17:55:07 up 1:51, 0 users, load average: 0.00, 0.03, 0.07
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
I cross checked with `who` and what not but it seems that nobody is ever logged in (although I am at the moment I am running `w`).
Why does `w` behave in this way ? How to fix this ? How to get what I want (the list of users currently logged in) ?
Thank you in advance for your help !
yms
PS I use Arch with dwm and I am logged in automatically at bootup (then xscreensaver locks the session). Tell me if you need some more information.
Sorry for any English mistakes, I am not a native speaker.
Offline
Perhaps $(users) is what you want?
Last edited by Wintervenom (2010-08-28 16:36:31)
Offline
I use Arch with dwm and I am logged in automatically at bootup
So do I:
[karol@black extra]$ w
18:49:12 up 7:24, 1 user, load average: 0,00, 0,00, 0,01
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
karol tty1 11:27 7:21m 3:36 0.01s /bin/sh /usr/bin/startx
Offline
Thank you for your answers but:
@Wintervenom: users is empty ... which is (unfortunately) consistent with w not showing anything ...
@karol: That's weird ... maybe we're not logged in in the same way. How do you proceed ?
Sorry for any English mistakes, I am not a native speaker.
Offline
I have
c1:2345:respawn:/sbin/mingetty --autologin karol tty1 linux
#c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
in my /etc/inittab.
I log into X manually via 'startx'.
Last edited by karol (2010-08-28 17:38:25)
Offline
In my /etc/inittab i have:
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
# ... other default stuff
x:5:once:/bin/su yms -l -c "/bin/bash --login -c startx >/dev/null 2>&1"
so I don't have to run startx myself. Maybe my thing is all wrong and just happens to work for logging in but creates the other(s) problems.
Any ideas ?
Sorry for any English mistakes, I am not a native speaker.
Offline
Try the ~/.bash_profile method http://wiki.archlinux.org/index.php/Start_X_at_Boot
Offline
The thing is, I don't use bash anymore (I switched to zsh) and I am trying to get rid of it wherever it is possible. I'll first try your way of autologin and run xorg manually to see if it changes anything as far as the original problem concerned.
I still would like to know what is going on and why my setup does not work the way it is :-/
Sorry for any English mistakes, I am not a native speaker.
Offline
The thing is, I don't use bash anymore (I switched to zsh) and I am trying to get rid of it wherever it is possible. I'll first try your way of autologin and run xorg manually to see if it changes anything as far as the original problem concerned.
I still would like to know what is going on and why my setup does not work the way it is :-/
How about putting it in .zshrc or whatever you have there? Maybe you need to fix some syntax issues but it should work.
Edit: I've just run
/bin/su karol -l -c "/bin/bash --login -c startx >/dev/null 2>&1"
and 'w' showed me logged on.
Last edited by karol (2010-08-29 18:27:02)
Offline
Hi,
I ran some tests and I found out that there are some flaws with all autologin techniques I tried.
1) What I have been using up to now:
x:5:once:/bin/su yms -l -c "/bin/bash --login -c startx >/dev/null 2>&1"
I (yms) do not show up in w, who, users etc.
2) Using mingetty like karol to autologin.
c1:2345:respawn:/sbin/mingetty --autologin yms tty1 linux
I am logged in correctly but I need to start Xorg myself or using a very hackish solution.
I am used to ugly hacks and sometimes they are a necessary evil but the problem is here that whenever my computer is locked (with xscreensaver) one can always switch to tty1 (Ctrl+Alt+F1), kill or pause startx and thus have access to a prompt ... This makes the whole locking thing ... useless.
Oh and if you run:
$ startx ; logout
so that if you kill startx then you are logged out and thus not getting access to a prompt, you'd be surprised because mingetty logs you back in immediately ;-)
@karol: I think you might have the same problem with your setup.
3) Using both the mingetty login and
x:5:once:/bin/su yms -l -c "/bin/bash --login -c startx >/dev/null 2>&1"
With this, you are logged in twice (and only appearing once in w, who, users etc which is still problematic (you should be appearing twice) ... Moreover, you have the same problem as in 2).
I really need a(n elegant) solution to this. Any ideas ?
Sorry for any English mistakes, I am not a native speaker.
Offline
I really need help on this one :-/ Anybody has an idea ?
Sorry for any English mistakes, I am not a native speaker.
Offline
I've already run out of ideas, but I run into a couple things that may confuse you, so I decided to post them here ;P
http://bugs.archlinux.org/task/15217#comment47079
Do me a favor: Run "bash -l" and then check lastlog. Random guess is that you may not be using a login shell
You log in with bash and use zsh for the rest of the day but I log in with dash and bash still shows '1 user'.
Slim issues:
https://bbs.archlinux.org/viewtopic.php?pid=672284
https://bbs.archlinux.org/viewtopic.php … 10#p335110
I'm not sure if any of this is of use.
Let's see where we are:
1. You want to fix '0 users' issue.
2. You want to log in into X automatically.
and
3. You want to lock your screen with xscreensaver.
While mingetty helps with the first, it somewhat complicates the second and breaks the third.
Have you looked into other tools like slock to securely lock your computer?
Last edited by karol (2010-09-04 19:14:50)
Offline