Since I haven’t posted in a while, I might as well post a few simple shell scripts that I use on my linux boxes to save time. The first I call ’scr’ which I use to reattach to detached screens. Program requirements for this one is ’screen’.
#!/bin/csh -f
set moo=`screen -ls | grep Detached | cut -d'(' -f1`
if ($moo != '') then
screen -r $moo
else
echo "no detached screens"
endif
This next one that I call ‘fm’ I use to satisfy my nervous ‘mailbox check’ habit. I drop that ‘date’ at the end so when I return to a shell, I can see the last time that I ran the command. Program requirement here: fetchmail and vi.
#!/bin/csh -f
set username="myusername"
set popserver="my.popserver.com"
cd
ls -al .mailbox1
set zz = `ls -sh ~/.mailbox1 | cut -d' ' -f1`
fetchmail -u "$username" -p POP3 -k -s $popserver -m cat > .mailbox1
set zy = `ls -sh ~/.mailbox1 | cut -d' ' -f1`
if (`echo $zz` != `echo $zy`) then
set zx = `cat .mailbox1 | wc -l`
if ($zx > 0) then
vi +/From: .mailbox1
endif
endif
date
Last script here that I call ‘vnc’ is for starting/stopping my vnc server. This is one service that I don’t like to keep running, so I just start and stop as I need it. I’m liking this 1250×950 geometry, most computers I use are 1280×1024, so the vnc client fits nicely on those screens. Program requirements: vncserver. Usage: vnc start | stop
#!/bin/bash
if [[ $1 == "start" ]]
then
vncserver -kill `hostname`:1
# vncserver -geometry 800×600
vncserver -geometry 1250×950
fi
if [[ $1 == "stop" ]]
then
vncserver -kill `hostname`:1
fi
if [[ $1 == "status" ]] || [[ $1 == "" ]]
then
z=`ps -A | grep Xvnc | wc -l`
if [[ $z == "0" ]]
then
echo “vnc server is off”
else
echo “vnc server is on”
fi
fi