linux-l: Shellscripte

Volker Mueller volker.mueller at gmx.de
Mo Jan 31 20:59:29 CET 2000


On Mon, 31 Jan 2000, Michael Weber wrote:

>> On Fri, 28 Jan 2000, Philipp Grau wrote:
>> Gut. Und wie schickt man wo Scripts hin? 
>
>First : ich hoffe dies wird keine HTML Mail... ich bin bei dem derzeit

soweit ich das gesehen habe, ist es das nicht.

>Wer Interesse hat an einer allgemeinen Shellscriptsammlung der
>schicke seine Scripte einfach an "sirewok at 01019freenet.de" -

Ok - ich attache mal eben was ...

>Gedacht sind erstmal "nur" Shellscripte.

Warum? Und wie definierst Du "Shellscript"? Auch phyton, perl,
tcl u.ae. kann man (so man denn will) als "shell" verwenden.

Tschau, Volker

-- 
<ESC>:r .signature
mailto:volker.mueller at gmx.de | http://www.in-berlin.de/user/flinux
:wq
-------------- nächster Teil --------------
#!/bin/bash
# /etc/suseppp/scripts/movemail
# Control onlinetime for fetching mails and news etc.
#
# Needs a lockfile $lockfile (see below) created by "/etc/ppp/ip-up"
# on start of fetching activities and deleted on end of fetching
# activities. The following example should give you an idea:
#
#---------< part of /etc/ppp/ip-up >------------------------------------
# [... /etc/ppp/ip-up ...]
#    case "$BASENAME" in
#    ip-up)
#      [... setting up firewalling rules ...]
#      [... setting up routes (if needed) ...]
#      [... setting up "online-sendmail" (if needed) ...]
#
##################################################################
#	# Add here (between "touch /tmp/trans_active" and "wait")
#	# the things to be done while we're online               
#	touch /tmp/trans_active                                  
##---vvv                                                          
#	date=$(date)                                             
#        /usr/sbin/sendmail -q &                                  
#        #/usr/bin/fetchmail -a -v >>/var/log/fetchmail 2>&1 &    
#	echo -n "------ $date ------ " >> /home/volker/fetchmail.log
#        su - volker -c "/usr/bin/fetchmail -a -v >> \            
#					/home/volker/fetchmail.log 2>&1" &
#	echo -n "------ $date ------ " >> /home/volker/dnetc.log 
#	su - volker -c "/home/volker/dnetc/dnetc -update >> \    
#					/home/volker/dnetc.log 2>&1" &
#        /usr/sbin/sendmail -q &                                  
##---^^^                                                          
#	wait                                                     
#	rm -f /tmp/trans_active                                  
##################################################################
#    ;;
#    ip-down)
#      [...]
#--------</ part of /etc/ppp/ip-up >------------------------------------
#
#  
#
# COPYRIGHT and WARRANTY: 
# This is free software and comes with absolutly no warranty.
# See the GPL for more details.
#
# Volker Mueller, 27.01.1999

#set -x

lockfile=/tmp/trans_active	# lockfile created by 
				# /etc/ppp/ip-up

pppd_pid_file=/var/run/ppp0.pid # pidfile created and deleted by 
				# /usr/sbin/pppd

ping_ip=192.109.42.0		# ip-adr. of one host which always should be 
				# reachable if we're online. This host will
				# be pinged until we get _one_ answer from it.

maxtime=900 	# MUST be defined in seconds! All trials and activities
		# will be canceled if this time is reached.

interval=2s	# interval to check for existing $lockfile (should be sth.
		# between 1 and 10 seconds - I think that 2 seconds are ok)

date=$(date)
echo ------ $date ------

starttime=$(date +%s)

/sbin/init.d/diald start&

sleep 2
echo
echo -n "Pinging wild around ..."
while [ $(ping -c1 $ping_ip 2>&1 | grep -c " 0% packet loss") != 1 ]; do
  # sometime there is nobody on the other end of the line. so we've to
  # check the $maxtime value here too.
  echo -n "."
  nowtime=$(date +%s)
  if test $(($nowtime - $starttime)) -gt $maxtime; then
    echo "Ooops - maxtime ($maxtime) reached :-("
    break
  fi
done

nowtime=$(date +%s)
timediff=$(($nowtime - $starttime))

echo
echo -n "Running main loop ..."

while test $timediff -lt $maxtime ; do
  nowtime=$(date +%s)
  timediff=$(($nowtime - $starttime))

  echo -n "."

  if ! test -e $lockfile ; then
    echo
    echo "No lockfile ($lockfile) from /etc/ppp/ip-up. Finishing the job after"
    echo appr. "$timediff seconds. (Hopefully correct ...)"
    /sbin/init.d/diald stop

    # sometimes pppd still lives after stopping diald. So kill it explicitly 
    # if it's still running.
    if test -e $pppd_pid_file; then
      echo "pppd is still running but it shouldn't."
      echo -n "Killing pppd ... "
      pppd_pid=$(cat $pppd_pid_file)
      kill $pppd_pid && echo "(PID: $pppd_pid Done."
    fi
    echo "... and now killing myself (PID: $$)."
    kill $$
  fi

  sleep $interval;
done

echo "$0 canceled because maxtime ($maxtime) is reached."
echo "Removing lockfile ($lockfile)."
rm -f $lockfile
echo
/sbin/init.d/diald stop
exit 1


Mehr Informationen über die Mailingliste linux-l