logger is a shell command interface to the syslog system log module, it appends a user-generated message to the system log (/var/log/messages). You do not have to be root to invoke logger.
Below is the simple bash script to log the debugging information to /var/log/message
Feel free to copy and use the below code
Source: cat logger.sh
#!/bin/bash
echo -n "Enter your username: "
read username
logger -i "Username $username started the script"
echo -n "Enter your Password: "
read password
# This is just an sample for comparing the password
if [ "$password" = "linuxpoison" ]; then
echo "welcome $username"
logger -i "Authentication successful for $username."
else
echo "your Username or password does not match"
logger -i "Authentication failed for $username."
fi
Continue Reading...
Below is the simple bash script to log the debugging information to /var/log/message
Feel free to copy and use the below code
Source: cat logger.sh
#!/bin/bash
echo -n "Enter your username: "
read username
logger -i "Username $username started the script"
echo -n "Enter your Password: "
read password
# This is just an sample for comparing the password
if [ "$password" = "linuxpoison" ]; then
echo "welcome $username"
logger -i "Authentication successful for $username."
else
echo "your Username or password does not match"
logger -i "Authentication failed for $username."
fi
0 comments:
Post a Comment