Bash Shell Script to Automate FTP File Transfer

Posted 195 days ago | 0 Comments

A little script to send a backup file to a remote FTP server: 12345678910111213141516#!/bin/bash HOST=’123.111.123.111′ USER=’bak_user’ PASSWD=’OpEnSeSaMe’ TODAY="$(date +"%Y%m%d")" FILENAME=Hostname_$TODAY.tgz cd /var/backup/sched/ ftp -n -v $HOST << EOT ascii user $USER $PASSWD prompt cd backups put $FILENAME ls -la bye EOT Then run it every day from Cron.

Continue Reading

Adaptec Hardware RAID controller on Sun 4150

Posted 197 days ago | 0 Comments

On our Oracle Sun x4150′s the Hardware Raid can be checked after installing the StorMan software which is available (as StorMan-6.40.x86_64.rpm)  in the software bundle for x4150s available after logging in to the Oralce support website and locating the downloads for x4150s. The download is pretty big (931MB) when the 39MB RPM is all you are [...]

Continue Reading

Using Sed to convert Mac Address

Posted 373 days ago | 0 Comments

I have output from a router (but I believe modem output may be similar) with mac addresses in the format: 0050.56AC.4022 Four digit blocks separated by dots but I needed it in the format of 2 digit blocks separated by colons. My router output was lines like this: INTERNET  123.111.123.111   8      0050.56AC.1765  ARPA  VLAN.1.16 [...]

Continue Reading

Web Screenshots with Xvfb and Khtml2Png2

Posted 435 days ago | 0 Comments

To get that headless Linux server capturing screenshots of web pages we need: Xvfb e.g. apt-get install xvfb Khtml2png2 (and dependencies) After installation of the above the steps are below and I wrapped it up into a PHP script which also did some database tasks to keep records of the screenshots. 1.Check if the Xvfb [...]

Continue Reading

Remove Line Breaks with tr

Posted 462 days ago | 0 Comments

I had a text file with multiple lines of input that I was manipulating using awk and sed but I found the following ‘tr’ command easiest to remove the line breaks: cat input.txt | tr -d ‘\n’

Continue Reading

Zero Filling a Disk in Linux

Posted 676 days ago | 1 Comments

The simple way to wipe or zerofill a disk is: dd if=/dev/zero of=/dev/sd? bs=1M However I found an article describing how to zero-fill with a progress indicator using pipebench, installed on Debian/Ubuntu with: sudo apt-get install pipebench then use: tr ‘\000′ ‘\377′ < /dev/zero | pipebench | sudo dd of=/dev/sd? Substitute the question mark for [...]

Continue Reading

Bash: Looping through Files with Spaces

Posted 815 days ago | 0 Comments

I was trying to move some miscellaneous music files into directories by artist name. The files (and folders) have spaces in the file names. For my first attempt I tries a for loop e.g. for file in $(find /path/to/music -type f); do … done A for loop will not do this regardless of how much [...]

Continue Reading

Finding, Searching, Replacing & Deleting Strings in Files

Posted 884 days ago | 0 Comments

To find a text string within files in all sub-directories: find . -type f | xargs -r0 grep -F ‘dodgystring’ or find . -type f -exec grep -l “dodgystring” {} \; To replace a string within files in all sub-directories: find ./ -type f -exec sed -i ‘s#fromstring#tostring#’ {} \; From within vi replacing all [...]

Continue Reading

echo with new lines

Posted 1501 days ago | 0 Comments

For future reference: echo “This does not give \n a new line” does not work. I had used printf sometimes but the -e switch also works for echo: echo -e “This gives \n a new line”

Continue Reading

nslookup mx records

Posted 1695 days ago | 0 Comments

$ nslookupDefault Server:  dnsserver.comAddress:  111.222.111.222> set q=mx> mymailserver.domain.com

Continue Reading