Run as a cron job every 15 minutes or so. Monitors your external IP address and sends you an email if it changes. This is useful if you run a server on an ISP that assigns IP addresses dynamically. Any time your IP address changes you'll want to be notified right away so you can hit up your domain registrar and update your A records, MX record, etc. Make sure you change the email address at the top to your email address. And obviously you need to have a mail server or forwarder set up for this to work.
#!/bin/bash EMAIL="email@example.com" SUBJ="IP Address change notification" IPADDR=`lynx --dump http://ipecho.net/plain` OLDIPADDR=`cat ~/ipaddr.txt` if [ "$IPADDR" = "" ]; then echo "Got empty response from ipecho.net" exit 1 fi if [ "$IPADDR" != "$OLDIPADDR" ]; then /usr/bin/mail -s "$SUBJ" "$EMAIL" <<EOM Your IP address appears to have changed: Old addr: $OLDIPADDR New addr: $IPADDR EOM fi echo "$IPADDR" > ~/ipaddr.txt exit $?
This will output the full path to a file or files in a directory. Useful when you need to get full paths to copy and paste into some other program, or you just need to generate a listing that shows the full path of every file. Any params you pass it will get passed on to the ls command. I've often wished ls could do this directly, so here is a way to make it do that. With a little tweaking, you could alias ls to this script, and make it pass everything directly to ls unless it finds a specific switch. If it finds the switch, it could do its thing, and if not, just act as a passthru to ls. Maybe I'll do that one day if I get some free time.
#!/bin/bash for file in $(ls "$@"); do echo -n $(pwd) [[ $(pwd) != "/" ]] && echo -n / echo $file done
Link each file in src-dir to target-dir. Thanks to Vasilios Alexiades at utk.edu for this one.
#!/bin/csh -f #--------- linkfiles: link each file from source_dir to targer_dir # usage: linkfiles srcdir tgtdir set src = "$1" set tgt = "$2" echo " " echo " --- linkfiles: link each file of srcdir into tgtdir --- " if( "$1" == "" ) then echo -n " --- linkfiles srcdir tgtdir ---> enter srcdir: " set src = $< endif if( "$2" == "" ) then echo -n " --- linkfiles srcdir tgtdir ---> enter tgtdir: " set tgt = $< endif /bin/ls "$src" > /tmp/list foreach fn ( `cat /tmp/list` ) set tgtfn = "$tgt"/"$fn" echo " ...... linking $fn ......" if( -f "$tgtfn" ) then echo " ------ $tgtfn exists ----" ls -o "$tgtfn" echo " ------ Enter y to overide (else wont): " set yesno = $< if( "$yesno" == "y" ) then ln -sf "$src"/"$fn" "$tgtfn" endif else ln -s "$src"/"$fn" "$tgt"/"$fn" ls -F "$tgt"/"$fn" sleep 1 endif echo "" end /bin/rm -f /tmp/list exit
Credit goes to Vasilios Alexiades at utk.edu for this one too. This will generate an html page with a link to each file in
the specified directory. Very useful if you need to make a bunch of files easily available through a web server. There are two
scripts here and they're too big to include inline here, so grab this .zip file
to download them.