Gtk Dialog And Python Gtk Windows are not displaying from cron job
- create one file named purval.sh
users=`grep -i "/bin/bash" /etc/passwd | cut -d':' -f1 | grep -v "root" >/tmp/.userss`
i=1
n=`wc -l < /tmp/.userss`
while [ $i -le $n ]
do
user=`awk "NR==$i" /tmp/.userss`
echo "user is $user"
export XAUTHORITY=/home/"$user"/.Xauthority
export DISPLAY=:0
/usr/bin/python /usr/bin/purval/warningmsg ( python Gtk source code / Gtk Window script)
i=$((i+1))
done
- add purval.sh file entry into /etc/crontab
Split the line from some character or special character
(In this example, split the line from (,) semi-colon)
/tmp/.chkk-11 file
sp-yes-This is the message, created by purval patel ,for testing
msg=`cat /tmp/.chkk-11 | cut -d'-' -f3`
if [ -n "$msg" ];
then
echo "message is not empty"
l=`echo "$msg" | grep -o ',' | wc -l`
max=`echo "$l" | tail -1`
lmax=$((max+1))
i=1
while [ $i -le $l ]
do
lnum="$i"
echo "$msg" | cut -d',' -f$i >>/tmp/.msg
i=$((i+1))
done
echo "$msg" | cut -d',' -f$lmax >>/tmp/.msg
else
echo "message is empty"
fi
List all XRDP users IP address
OR
List all users UP whos taken RDP of server
ipc=` grep -i "\[2017" /var/log/xrdp-sesman.log | grep -o " ip [0-9]*.[0-9]*.[0-9]*.[0-9]*" | wc -l`
usc=`grep -i "\[2017" /var/log/xrdp-sesman.log | grep -i " ip [0-9]" | grep -o "username [a-z0-9]*" | awk '{print$2}' | wc -l`
ips=`echo "$ipc" | tr -d '\b\r'`
uc=`echo "$usc" | tr -d '\b\r'`
rm -rf /tmp/ulist
echo $ips
echo $uc
if [ "$ips" -eq "$uc" ];
then
grep -i "\[2017" /var/log/xrdp-sesman.log | grep -i " ip [0-9]" | grep -o "username [a-z0-9]*" | awk '{print$2}' >/tmp/.users
sed -i '/^\s*$/d' /tmp/.users
grep -i "\[2017" /var/log/xrdp-sesman.log | grep -o " ip [0-9]*.[0-9]*.[0-9]*.[0-9]*" | awk '{print$2}' >/tmp/.ips
sed -i '/^\s*$/d' /tmp/.ips
i=0
n=`wc -l </tmp/.users`
while [ $i -le $n ]
do
user=`awk "NR==$i" /tmp/.users`
ip=`awk "NR==$i" /tmp/.ips`
echo "$user=$ip " >>/tmp/ulist
i=$((i+1))
done
echo "finishing..."
cat /tmp/ulist | sort -u >/tmp/usersiplist
echo "completed"
fi
Use Printf in shell script
printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
Monitoring System Performance
#!/bin/bash
ifconfig eth0 | grep -i "inet addr" | awk '{print$2}' | cut -d':' -f2
CPU=`top -b -n1 | grep -i "load average" | awk '{print$10}' | sed 's/,/ /g'`
echo "$CPU"
## RAM usage
FREE_DATA=`free -m | grep Mem`
CURRENT=`echo $FREE_DATA | cut -f3 -d' '`
TOTAL=`echo $FREE_DATA | cut -f2 -d' '`
FREE=`echo $FREE_DATA | cut -f4 -d' '`
echo "$FREE/$CURRENT/$TOTAL MB"
echo HDD: `df -lh | awk '{if ($6 == "/") { print $5 }}' | head -1 | cut -d'%' -f1`
## curunt Users
users=`ps -ef | grep -i X11rdp | grep -v "color" | grep -v "grep" | wc -l `
echo "$users"
### network load
awk '{if(l1){print ($2-l1)/1024,($10-l2)/1024} else{l1=$2; l2=$10;}}' <(grep eth0 /proc/net/dev) <(sleep 1; grep eth0 /proc/net/dev) >/tmp/.netspeed >/tmp/.netkbyte
dload_kbyte=`cat /tmp/.netkbyte | awk '{print$1}'`
uload_kbyte=`cat /tmp/.netkbyte | awk '{print$2}'`
incoming=${dload_kbyte%.*}
outgoing=${uload_kbyte%.*}
echo "network load"
recv=$((incoming*8))
echo "Downloading speed $recv KBit"
sent=$((outgoing))
echo "Upload speed $sent KBit"
Store Logs into /var/log/syslog using C Programming
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
int main(void) {
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);
syslog(LOG_INFO, "A different kind of Hello world ... ");
closelog();
return 0;
}
compile Program:
gcc program1.c -o programcx
./programcx
Menus from lxpanel are removed after installing CANON-UFRII drivers in Lubuntu ?
faced one issue after installing Canon-UFRII driver for canon printers in Lubuntu Desktop OS.
i.e. Menus from Lxpanel is removed.
only two menus are showing run and logout.
Solution:
remove the below file,
mv / usr/share/applications/cnsetuputil.desktop /opt
it works .
Thank you,
-bash: mkfs.vfat: command not found
Error while setting up partition label.
package is : dosfstools
You may install the required package with command apt-get install {package}
- create one file named purval.sh
users=`grep -i "/bin/bash" /etc/passwd | cut -d':' -f1 | grep -v "root" >/tmp/.userss`
i=1
n=`wc -l < /tmp/.userss`
while [ $i -le $n ]
do
user=`awk "NR==$i" /tmp/.userss`
echo "user is $user"
export XAUTHORITY=/home/"$user"/.Xauthority
export DISPLAY=:0
/usr/bin/python /usr/bin/purval/warningmsg ( python Gtk source code / Gtk Window script)
i=$((i+1))
done
- add purval.sh file entry into /etc/crontab
Split the line from some character or special character
(In this example, split the line from (,) semi-colon)
/tmp/.chkk-11 file
sp-yes-This is the message, created by purval patel ,for testing
msg=`cat /tmp/.chkk-11 | cut -d'-' -f3`
if [ -n "$msg" ];
then
echo "message is not empty"
l=`echo "$msg" | grep -o ',' | wc -l`
max=`echo "$l" | tail -1`
lmax=$((max+1))
i=1
while [ $i -le $l ]
do
lnum="$i"
echo "$msg" | cut -d',' -f$i >>/tmp/.msg
i=$((i+1))
done
echo "$msg" | cut -d',' -f$lmax >>/tmp/.msg
else
echo "message is empty"
fi
List all XRDP users IP address
OR
List all users UP whos taken RDP of server
ipc=` grep -i "\[2017" /var/log/xrdp-sesman.log | grep -o " ip [0-9]*.[0-9]*.[0-9]*.[0-9]*" | wc -l`
usc=`grep -i "\[2017" /var/log/xrdp-sesman.log | grep -i " ip [0-9]" | grep -o "username [a-z0-9]*" | awk '{print$2}' | wc -l`
ips=`echo "$ipc" | tr -d '\b\r'`
uc=`echo "$usc" | tr -d '\b\r'`
rm -rf /tmp/ulist
echo $ips
echo $uc
if [ "$ips" -eq "$uc" ];
then
grep -i "\[2017" /var/log/xrdp-sesman.log | grep -i " ip [0-9]" | grep -o "username [a-z0-9]*" | awk '{print$2}' >/tmp/.users
sed -i '/^\s*$/d' /tmp/.users
grep -i "\[2017" /var/log/xrdp-sesman.log | grep -o " ip [0-9]*.[0-9]*.[0-9]*.[0-9]*" | awk '{print$2}' >/tmp/.ips
sed -i '/^\s*$/d' /tmp/.ips
i=0
n=`wc -l </tmp/.users`
while [ $i -le $n ]
do
user=`awk "NR==$i" /tmp/.users`
ip=`awk "NR==$i" /tmp/.ips`
echo "$user=$ip " >>/tmp/ulist
i=$((i+1))
done
echo "finishing..."
cat /tmp/ulist | sort -u >/tmp/usersiplist
echo "completed"
fi
Use Printf in shell script
printf "Welcome to %s (%s %s %s)\n" "$DISTRIB_DESCRIPTION" "$(uname -o)" "$(uname -r)" "$(uname -m)"
Monitoring System Performance
#!/bin/bash
ifconfig eth0 | grep -i "inet addr" | awk '{print$2}' | cut -d':' -f2
CPU=`top -b -n1 | grep -i "load average" | awk '{print$10}' | sed 's/,/ /g'`
echo "$CPU"
## RAM usage
FREE_DATA=`free -m | grep Mem`
CURRENT=`echo $FREE_DATA | cut -f3 -d' '`
TOTAL=`echo $FREE_DATA | cut -f2 -d' '`
FREE=`echo $FREE_DATA | cut -f4 -d' '`
echo "$FREE/$CURRENT/$TOTAL MB"
echo HDD: `df -lh | awk '{if ($6 == "/") { print $5 }}' | head -1 | cut -d'%' -f1`
## curunt Users
users=`ps -ef | grep -i X11rdp | grep -v "color" | grep -v "grep" | wc -l `
echo "$users"
### network load
awk '{if(l1){print ($2-l1)/1024,($10-l2)/1024} else{l1=$2; l2=$10;}}' <(grep eth0 /proc/net/dev) <(sleep 1; grep eth0 /proc/net/dev) >/tmp/.netspeed >/tmp/.netkbyte
dload_kbyte=`cat /tmp/.netkbyte | awk '{print$1}'`
uload_kbyte=`cat /tmp/.netkbyte | awk '{print$2}'`
incoming=${dload_kbyte%.*}
outgoing=${uload_kbyte%.*}
echo "network load"
recv=$((incoming*8))
echo "Downloading speed $recv KBit"
sent=$((outgoing))
echo "Upload speed $sent KBit"
Store Logs into /var/log/syslog using C Programming
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
int main(void) {
openlog("slog", LOG_PID|LOG_CONS, LOG_USER);
syslog(LOG_INFO, "A different kind of Hello world ... ");
closelog();
return 0;
}
compile Program:
gcc program1.c -o programcx
./programcx
Menus from lxpanel are removed after installing CANON-UFRII drivers in Lubuntu ?
faced one issue after installing Canon-UFRII driver for canon printers in Lubuntu Desktop OS.
i.e. Menus from Lxpanel is removed.
only two menus are showing run and logout.
Solution:
remove the below file,
mv / usr/share/applications/cnsetuputil.desktop /opt
it works .
Thank you,
-bash: mkfs.vfat: command not found
Error while setting up partition label.
package is : dosfstools
You may install the required package with command apt-get install {package}
No comments:
Post a Comment