# The \`who\` command.... How can I see the result in NR?

**URL:** <https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930>\
**Category:** General\
**Created:** [13 September 2024 04:49 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930 "2024-09-13T04:49:58Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 04:49 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/1 "2024-09-13T04:49:58Z")

</div>

Maybe I'm being paranoid.... 😉

I'm wanting to run the command `who` now and the and get the result back as something NR can handle.

```auto
pi@TimePi:~ $ who
pi tty1 2024-06-01 22:32
pi tty7 2024-06-01 22:32 (:0)
pi pts/1 2024-09-13 14:48 (192.168.17.6)
pi@TimePi:~ $ 

```

So that would ....... give me...... `3`.  
_SOMETHING_ that if more people log in, it increases.

Thoughts?

---

<div class="post-metadata">

**Author:** ![stefan24](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/stefan24/32/23075_2.png) [@stefan24](https://discourse.nodered.org/u/stefan24)\
**Post date:** [13 September 2024 05:23 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/2 "2024-09-13T05:23:48Z")

</div>

```auto
who | wc -l

```

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 September 2024 06:19 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/3 "2024-09-13T06:19:30Z")

</div>

simple flow with a `who | wc -l` and a switch ...

 ![Screenshot 2024-09-13 at 08.19.10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/f/ff9c8759904ff5e6a5ea0853223cf8ac2b31f445.png)

```auto
[{"id":"ef091c04beb228ca","type":"exec","z":"37731ca11bbd1b42","command":"who | wc -l","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":626,"y":360,"wires":[["974751273bbe2ff3"],[],[]]},{"id":"b5caf2dcc5d99384","type":"inject","z":"37731ca11bbd1b42","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":385,"y":360,"wires":[["ef091c04beb228ca"]]},{"id":"974751273bbe2ff3","type":"switch","z":"37731ca11bbd1b42","name":"","property":"$number($parseInteger($trim($$.payload), '#0'))","propertyType":"jsonata","rules":[{"t":"gt","v":"3","vt":"num"},{"t":"gt","v":"2","vt":"num"},{"t":"gt","v":"1","vt":"num"},{"t":"gt","v":"0","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"false","repair":false,"outputs":5,"x":804,"y":347,"wires":[["fab6c974689f21df"],["f9891084d34f65b0"],["107bf6521d8d7f6e"],["129a7599f3ef1a04"],["eec31dbe9a35fcde"]]},{"id":"fab6c974689f21df","type":"debug","z":"37731ca11bbd1b42","name":"> 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":996,"y":250,"wires":[]},{"id":"f9891084d34f65b0","type":"debug","z":"37731ca11bbd1b42","name":"> 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":996,"y":298,"wires":[]},{"id":"107bf6521d8d7f6e","type":"debug","z":"37731ca11bbd1b42","name":"> 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":996,"y":346,"wires":[]},{"id":"129a7599f3ef1a04","type":"debug","z":"37731ca11bbd1b42","name":"> 0","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":996,"y":394,"wires":[]},{"id":"eec31dbe9a35fcde","type":"debug","z":"37731ca11bbd1b42","name":"== 0","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":998,"y":439,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:23 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/4 "2024-09-13T07:23:50Z")

</div>

Ok, thanks.

I'm slightly confused though.

```auto
pi@BedPi:~ $ who
pi tty1 2023-10-03 06:43
pi tty7 2023-10-03 06:43 (:0)
pi pts/0 2024-09-13 17:26 (192.168.17.6)
pi@BedPi:~ $ 
 

```

When I run the flow on that machine I get

 ![Screenshot from 2024-09-13 17-22-46](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f6ce713874a21d13978730c65f69a598484637fe.png)

Ummmm...

# HANG ON!

Ok, edited the CLI paste.  
(Sucks sometimes when you are remoted into a few machines.)

So - sorry - the problem/confusion remains.  
(Original paste was from a different machine)

Ah!  
Ok, so if I am not `ssh` into the machine, it is 2, and if I `ssh` in I get 3.

# SORRY!

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 September 2024 07:34 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/5 "2024-09-13T07:34:58Z")

</div>

the flow is differentiating between count of users - so the debug you're seeing is coming from the debug labeled "\> 1", i.e. you have two users and that's greater than one but less than two!

basically you can remove the switch but it does give you a JSONata expression to convert the string "2\n" to a number 2 - that might be useful.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:35 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/6 "2024-09-13T07:35:28Z")

</div>

Oh, sorry, a quickie which I did just realise is _problematic_ with how that works.

So, with no remote login (by me) the number I get is the `2`.

But I'm wanting to know if......

_Thinking as I am typing_

Ok, so I then _join_ all the **OTHER** outputs from the `switch` node that are NOT wanted.

Then if any of them are sent: I am notified?

Yes?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:36 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/7 "2024-09-13T07:36:06Z")

</div>

Yeah, sorry. That was my mistake.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 September 2024 07:38 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/8 "2024-09-13T07:38:08Z")

</div>

So you want to know "who is logged into my raspberry who isn't me"?

That's isn't easy if you have one user, i.e. pi. I guess using the ip on the who output and filtering on that might help ....

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:39 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/9 "2024-09-13T07:39:50Z")

</div>

Not really. Just to get a notification of the number goes above the _normal_ one.

I'm testing the idea I just said.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 September 2024 07:46 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/10 "2024-09-13T07:46:19Z")

</div>

> [@Trying\_to\_learn](#):
>
> the number goes above the _normal_ one.

Ok let me rephrase my assumption: "who is logged into my raspberry who isn't _normal_"? 😉

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:47 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/11 "2024-09-13T07:47:12Z")

</div>

Yeah... Sorry I didn't mean to be difficult.

Though the idea I had - posted - does seem to be a good one.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 September 2024 07:47 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/12 "2024-09-13T07:47:57Z")

</div>

> [@Trying\_to\_learn](#):
>
> Then if any of them are sent: I am notified?

ok so you want the notify logic on the outputs of the `switch` that is greater than 1 i.e. '\>1', '\>2' and '\>3' - the top three debug nodes.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 September 2024 07:49 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/13 "2024-09-13T07:49:13Z")

</div>

> [@Trying\_to\_learn](#):
>
> Sorry I didn't mean to be difficult.

Not at all 🙂 All good! I tend to read only half the questions, so my answers tend to be misguided!

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:49 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/14 "2024-09-13T07:49:20Z")

</div>

This seems to work.

 ![Screenshot from 2024-09-13 17-48-38](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/3/b3a3f7b8bf7dff961e1ea550d00a9e4a113be6d3.png)

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [13 September 2024 07:50 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/15 "2024-09-13T07:50:51Z")

</div>

but you have also connected to '== 0' and '\> 0' that will also send a notification when no one is logged in or just one ...

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:54 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/16 "2024-09-13T07:54:17Z")

</div>

Me being anal.

But I though of that way after asking the better question.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [13 September 2024 07:58 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/17 "2024-09-13T07:58:11Z")

</div>

I'll accept your idea - with my mod - as the answer.

Thanks.

Now I've got a lot of problems with queued MQTT messages.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [27 September 2024 08:03 UTC](https://discourse.nodered.org/t/the-who-command-how-can-i-see-the-result-in-nr/90930/19 "2024-09-27T08:03:36Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
