Knoxvilles_joker
Refugee
So I was trying to figure out how to get command results such as how many players are on a server at a given point in time.
so let's make a file in /usr/local/bin. Let us name it telnetlog.sh. Invoke creation with: sudo nano telnetlog.sh. Paste the following into the file:
#!/usr/bin/
# Specify the log file
set log_filename "telnet.log"
# Open the log file for writing (appending with -a, or overwriting by default)
# To append: log_file -a $log_filename
# To overwrite: log_file $log_filename
log_file -a $log_filename
set timeout -1
spawn telnet localhost 8081
expect " "
send "serverpassword\n"
expect " " # wait for console prompt
send "lp\r" # this list players
sleep 1 # wait for command to finish
expect " "
send "exit\r"
expect eof
log_file
exit
------------------------------------------------------------------
now modify the file with execute permisions with: sudo chmod +x /usr/local/bin/telnetlog.sh
now create the log file with : sudo nano /usr/local/bin/telnet.log, hit enter hit ctrl + x, y + enter
I already have a weekly log cleaner that runs so I append this text to that file cleanlog.sh in /usr/local/bin:
cat /dev/null > /usr/local/bin/telnet.log
Now we add it to crontab with: sudo crontab -e
and add:
@hourly /usr/local/bin/telnetlog.sh
so let's make a file in /usr/local/bin. Let us name it telnetlog.sh. Invoke creation with: sudo nano telnetlog.sh. Paste the following into the file:
#!/usr/bin/
# Specify the log file
set log_filename "telnet.log"
# Open the log file for writing (appending with -a, or overwriting by default)
# To append: log_file -a $log_filename
# To overwrite: log_file $log_filename
log_file -a $log_filename
set timeout -1
spawn telnet localhost 8081
expect " "
send "serverpassword\n"
expect " " # wait for console prompt
send "lp\r" # this list players
sleep 1 # wait for command to finish
expect " "
send "exit\r"
expect eof
log_file
exit
------------------------------------------------------------------
now modify the file with execute permisions with: sudo chmod +x /usr/local/bin/telnetlog.sh
now create the log file with : sudo nano /usr/local/bin/telnet.log, hit enter hit ctrl + x, y + enter
I already have a weekly log cleaner that runs so I append this text to that file cleanlog.sh in /usr/local/bin:
cat /dev/null > /usr/local/bin/telnet.log
Now we add it to crontab with: sudo crontab -e
and add:
@hourly /usr/local/bin/telnetlog.sh