Results 1 to 4 of 4
  1. #1
    Join Date
    November 2015

    Bash script to check if there is any users online?

    Hey guys,

    I have a TS3 server running on Linux (open media vault) and I am just wondering if there is any way to check if there is users online from a bash script. My current setup turns the server on at 12:00 pm and it turns off automatically turns off at 4:00 am. Problem is sometimes I am talking to my friends past this time and the server would shut down. So I would like a script that I can run at 4:00 am to check if there is any users online, if there is any user connected to the TS then it wont shut down and keeps checking this every 15 minutes, then once there is nobody on it will then shut down the server. Problem is I cannot find a way to get the amount of players online into a bash script. From what I have read you need to use the serverquery and check that way somehow(which I'm not too familiar with). I'm kind of new to Linux and don't know a whole lot(taken a few intro courses and i can write basic bash scripts), I'm just wondering if anyone knows how to get the current online users from the CLI.

    Last edited by dante696; November 26th, 2015 at 01:14 PM. Reason: moved to tools section

  2. #2
    Join Date
    February 2012
    You can use netcat (nc) to connect to the query admin interface and get a list of clients:

      echo -e "use $_instance\nlogin $_user $_pass\nclientlist -ip\nquit" | \
      nc $_host $_port | tr -d "\r" | {
        while read -r line; do
          echo "$line"
      } || return 1
    exit 0
    You can go from there with usual bash scripting (cut, grep, xargs).
    You don't need serveradmin for this, a unprivileged client whom you give a query admin password should work as well as long as he has permission to use the clientlist command.

  3. #3
    Join Date
    December 2004
    Using bash, it is much more simple.

    exec 8<>/dev/tcp/localhost/10011
    while read -r -t 1 -u 8 REPLY; do :; done
    printf "use 1\r\n" >&8
    read -r -t 1 -u 8 REPLY
    echo "$REPLY"
    However, this do have a caveat with TS3 query console, because for some backward reason it uses \n\r as EOL.

    NB: Do NOT use 'echo' to communicate with other systems, it does not produce consistent results across operating systems.

  4. #4
    Join Date
    March 2019

    Bash script to check if there is any users online?

    Hey all I hope you can help me with my little problem. I running a local ts server on my NAS (openmediavault) for me an my friends. I‘m trying to get a list of how many users are online. My nas runs an autoshutdown plugin to shutdown the system if it is not in use. It has the ability to check on conected ports but its not working with teamspeak. So I need a script that lets me output the number of online users so I can tell the shutdown plugin if there is more then one user online don‘t shut down.Nox VidMate Mobdro
    Last edited by romangiggles; March 5th, 2019 at 07:45 PM. Reason: merged

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. bash script to backup ts3 settings
    By rommyappus in forum Linux / FreeBSD
    Replies: 1
    Last Post: August 26th, 2015, 05:46 PM
  2. Need Script to check if server is online
    By skinhead in forum Tools / Web Based
    Replies: 7
    Last Post: May 11th, 2014, 10:50 PM
  3. Replies: 15
    Last Post: April 23rd, 2013, 08:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts