Wake on LAN via Windows

Windows

To wake a machine from a Windows computer there are a few choices.

wolcmd

wolcmd for the command line from Depicus.com is good to use in scripts or by itself. It works 100% of the time for me.

 wolcmd yourmacaddr localserveripaddr 0.0.0.0 9

wolcmd can start the Linux server using wolcmd <-download page, from Depicus.com

Wake on LAN GUI

A GUI version of the wolcmd tool from Depicus.com WakeOnLanGui

WOL Magic Packet Sender Tool

WOL Magic Packet Sender, uses a WOL Setup MSI file.  I have used this quite a bit and it does work nicely. It is the first one that I used and have it on my Windows machines.

Online

At Depicus.com you can wake your machine directly from the Internet as well without loading any application via this page –> http://www.depicus.com/wake-on-lan/woli.aspx

There is even a way with the Depicus site to make up a URL that will have the MAC address, IP address and Port as parameters to send a magic packet. I’ve tried it and it works.

 

 

 

 

Tuscan Style Chicken Thighs

This is a recipe that I saw on TV, don’t remember the show. But I have since modified the recipe. I chose chicken thighs, they are generally moister as they contain more dark meat. This recipe can also be done with an entire chicken splayed or a half chicken.

Tuscan Chicken Thighs Plated
Tuscan Chicken Thighs Plated

Ingredients

2 Large onions

2 Large carrots

2 Celery stalks

4-6 Potatoes depending on size

4 Chicken thighs

1 Lemon, preferably preserved

Paprika

Old Bay

3 tbsp Dried rosemary, 1 for the thighs, 2 for the potatoes

4-8 Cloves garlic

Salt

Olive Oil

Tuscan Chicken Thighs, Chicken Ready For Oven
Tuscan Chicken Thighs, Chicken Ready For Oven

 Process

  • Set oven to 425 F
  • Cut up onions into 3/4 inch slabs and lay in bottom of casserole or cast iron pan
  • Peel carrots, cut into 1 inch pieces, add on top of onions
  • Celery cut into 1 inch pieces, add on top of onions
  • Clean skin of potatoes, quarter them, toss in bowl with salt ( to taste preference) 2 tbsp Rosemary and 2 tbsp Olive Oil. Put on top of other vegetables
  • Put in oven for 30 minutes, covered if possible
  • Rinse chicken thighs and do not remove skin, but loosen it gently to provide a pocket for the lemon and garlic
  • Take 1/4 Lemon, 1 or 2 cloves of garlic and a pinch of rosemary and stuff under the skin
  • Apply paprika, old bay and salt to taste preferences to the outside of the skin
  • After vegetables have cooked for 30 minutes, remove casserole/iron pan and place chicken on top of vegetables and then it goes back in the oven, 15 more minutes at 425F
  • Reduce heat to 375F, continue backing for approximately 1 to 1-1/4 hours until vegetables become soft
  • Remove chicken and allow to rest for 10 minutes
  • While chicken is resting, it is possible to mix vegetables around and broil them a bit until browned a bit

Tuscan Chicken Thighs, Vegetables

 

Automatic Server Status Page Creation

On one of the servers I ran in 2013-14, I used Webmin to keep track of what was going on with the server, memory usage, drive space and so on. It was a bit overkill, I thought I would need it more than I really did.

The server I am trying this out on is resource limited, low RAM mostly, only 512MB. So I was concerned about too many processes weighing it down and was trimming RAM use for Apache, mySql and PHP. I wanted an easy way to look at what is going on with the server, web based, so putting the info on a dynamically created page seemed like the way to go.

Restricting Directory Access with Apache

I don’t want just anyone to have access to the status directory. Clever folks might gain too much insight from what is shown there, a potential hack risk. On the server the location /var/www/status is restricted. What I mean by this is that I have edited the Apache default file to restrict access by IP, as I am only accessing this from a few IP’s. Below is an example of the mod to the Apache default file. Obviously I want to allow from my local net, so that is 192.168.1 ranging from 0-255. In the default file you don’t have to list the entire IP if you want to cover a range. Additionally at the time, there were a few IP’s in the 74.67.XX.XX range so I opened that range up for testing access to. Basically you can add as many as you want. Another option would be to password protect the directory, but for now this is all I need.

To edit the Apache default file, make a backup copy first, then on Ubuntu at least…

sudo nano /etc/apache2/sites-available/default
Example code from Apache default file to allow certain IP’s access to a directory and deny all others
<Directory /var/www/status/>
        Order deny,allow
        Allow from 192.168.1
                Allow from 74.67
    
        Deny from all
</Directory>

Logcreate

With this server instead of using Webmin to look at the status of the server,  I made a simple file called logcreate, ran by putting it in the cron.hourly folder and chmodding it +x! It makes a status page at /var/www/status/log.txt. Also generated is /var/www/status/fulllog.txt a concatenated version of the log.txt added to on an hourly basis. I used dash instead of bash, it’s a slight improvement in memory use when called. Don’t use an extension, cron won’t run files such as logcreate.sh.

Logcreate basically it gives you a synopsis of the servers state in text form…

  • Date and time stamp on top ( date )
  • Tail of the syslog ( tail /var/log/syslog )
  • Memory usage ( free )
  • Drive space usage ( df -h )
  • Processes sorted by RAM usage ( ps aux | sort -nrk 4 | head )
  • Free standing copy of the process tree ( pstree )

 

The code for logcreate, the file to be placed in /etc/cron.hourly
#!/bin/dash
# Remove old log
rm /var/www/status/log.txt
# Print logged outputs into new log.txt 
# Starting with date stamp
date >> /var/www/status/log.txt
echo >> /var/www/status/log.txt
# Grab the tail of the syslog file
tail /var/log/syslog >> /var/www/status/log.txt
echo >> /var/www/status/log.txt
# Log RAM usage
free >> /var/www/status/log.txt
echo >> /var/www/status/log.txt
# Disk Usage
df -h >> /var/www/status/log.txt
echo >> /var/www/status/log.txt
# Top memory using processes http://www.commandlinefu.com/commands/view/3/display-the-top-ten-running-processes-sorted-by-memory-usage
#ps aux | sort -nk +4 | tail >> log.txt
#echo 'USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND ' >> log.txt
ps aux | sort -nrk 4 | head >> /var/www/status/log.txt
echo >> /var/www/status/log.txt
echo >> /var/www/status/log.txt
# Copy log.txt into the full log that is collected from the hourly updates.
cat /var/www/status/log.txt >> /var/www/status/fulllog.txt
# Create a free standing copy of the process tree
pstree > /var/www/status/pstree.txt

 

Resources

Figuring out a good command to list the running processes sorted by RAM use was something I needed some help figuring out as far as the best way to do it. The link below was where I got my info from.

Top memory using processes:  http://www.commandlinefu.com/commands/view/3/display-the-top-ten-running-processes-sorted-by-memory-usage

Backing up Windows User’s to Folders to a Linux File Server

Robust File Copy for Windows

robocopy.exe available as part of rktools <-download page, can be used to copy files across the network to a Linux machine into a folder setup using Samba.

The DOS batch file below is called serverbackup.bat on my machine. It can start the Linux server using wolcmd <-download page, from Depicus.com and will copy a users folder to a folder on the server and creates a log file C:\tools\backup.log, then it shuts down the Windows PC with a 120 second delay. This delay is mostly there for testing. If the robocopy command goes belly up, the PC will try to jump right to the shutdown, which makes troubleshooting difficult. So leaving a delay is helpful as one can abort a shutdown by executing…

shutdown /a

…from the command line in Windows to stop the machine from shutting down.

I had to review how robocopy worked before deploying it in a backup script and I found an exact example of what I was looking for on Jacob Surland’s photography blog Caught in Pixels. I reviewed his post How to create a backup script using Robocopy before writing the serverbackup.bat script. I have the script downloadable here named serverbackup.bat, rename and modify as needed.

REM Wake Server, if it is already on, no harm done. It takes about 17 secs for server to start so REM robocopy will get an error and should keep retrying
REM run Depicus Wake on Lan from Command Line. Validated, Works!
 wolcmd yourmacaddr localserveripaddr 0.0.0.0 9
REM Copy User folder to \files\user on server via Samba links
 REM /MIR = purge files from dest. that do not exists in source
 REM /M Copy Archiveable files & reset attribute - not using this yet!!!
 REM /XA:SH exclude system and hidden important for user space
 REM /FFT fixes timing up for LINUX assumes FAT file times ( 2 sec granularity)
robocopy "C:\Documents and Settings\Erick_2" \\UBUNTUSERVER\Erick_Backup /MIR /XA:SH /XJ /FFT /W:1 /R:5 /LOG:C:\tools\backup.log
REM Shutdown PC when backups are done
shutdown -s -f -t 120

So far it works….

Resources

Windows Server 2003 Resource Kit Tools aka rktools

Depicus wolcmd download page

How to create a backup script using Robocopy

 

Creating a Bootable USB Drive

A bootable USB works great, it can be very helpful at times. And it is now so easy to create a bootable USB drive with a Linux Distro of your choice. The bootable USB stick works like the Live CD but with the advantage of persistence. Persistence means you can load programs on the USB drive, unlike the Live DVD. Plus settings are remembered. It also means that you can load tools on it to help rescue a broken computer, Windows or Linux. I have rescued many a PC (Windows) by booting using Linux and copying files off and rescuing them. Or you can replace bad files directly. It is like carrying  a “computer” that you can keep in your pocket and plug into a PC and have it boot right into an environment you have set up for your self. Just be aware that certain PC’s that run Windows 8 try to block the ability to boot off of external devices. You have to go into the BIOS and switch off or over ride this behavior of the so called boot protection. It usually requires one to enter a 4 digit code when you leave the BIOS. Some PC’s flash this briefly, too fast to see in my opinion.

I installed Linux Mint XFCE 32bit on a USB drive recently. XFCE mostly for the fact that XFCE is light and will run on just about any PC, 32 bit will run on both 32 and 64 bit machines. Mint because I haven’t tried it yet and a bootable USB drive would make a good test drive, especially since I can do a lot more than I can with just the Live CD. The USB drive I bought for this was off of eBay, I opted for a USB 3.0 device for the speed when a machine has USB 3.0.

Linux command line using dd

Linux as well using dd to copy from the iso to the usb drive, make sure you know where the drive is mounted when doing this via the command line. Use sudo fdisk -l to list all of your mount points. Alternatively you can use  lsblk and you will see mounted and unmounted devices.

See the sdb1 below all of the info about sda1 ( hard drive )….

Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *           1        3648    29296875    7  HPFS/NTFS
 /dev/sda2            3648        9729    48850529+   5  Extended
 /dev/sda5            9668        9729      497983+  82  Linux swap / Solaris
 /dev/sda6            3648        9667    48352256   83  Linux
Partition table entries are not in disk order
Disk /dev/sdb: 16.1 GB, 16079781888 bytes
 256 heads, 9 sectors/track, 13631 cylinders
 Units = cylinders of 2304 * 512 = 1179648 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0xc3072e18
Device Boot      Start         End      Blocks   Id  System
 /dev/sdb1   *           8       13631    15694808    7  HPFS/NTFS

 

To burn ISO to sdb1 for example…

sudo dd if=~/Desktop/linuxmint.iso of=/dev/sdb1 oflag=direct bs=1048576

oflag=direct may not always work, leave it out if the copy fails. For more on doing this from Linux see the link below.

Mounting USB Drive from the Linux Command Line

First use fdisk -l or lsblk to find the location of the drive. Then for example to mount a usb drive at /dev/sdc1 to /mnt/sdc1 use…

 sudo mount /dev/sdc1 /mnt/sdc1

You can choose a mountpoint other than mnt, Linux can mount a drive to just about any folder you create. That is the beauty of it over lettered drives like Windows uses.

Universal USB Installer

The Universal USB Installer allows you to do all of this from Windows,

How to create a bootable Linux Mint USB drive using Windows…
http://www.everydaylinuxuser.com/2014/05/how-to-create-bootable-linux-mint-usb.html

 Test Drive

I have tried the drive on a fast machine with USB 3.0. Dell quad core 2.4GHz, 8GB RAM. It does boot fast, not as fast as a hard drive but very reasonable. I was able to stream video and watch TV with it, play DVD’s and adjust the screen saver NOT to come on.

A mom and her son watch the mushroom cloud after an atomic test 75 miles away, Las Vegas , 1953.

A mom and her son watch the mushroom cloud after an atomic test 75 miles away, Las Vegas , 1953.
A mom and her son watch the mushroom cloud after
an atomic test 75 miles away, Las Vegas , 1953.

 

 

I’d love to have seen a nuke go off, from a safe distance of course. The scientist Richard Feynman was the only one at the Trinity test to view it in full glory without eye shielding. He figured sitting in a car the glass would not let the dangerous UV rays pass though, which is true. I read about this in the great book The Making of the Atomic Bomb, about the Manhattan Project by Richard Rhodes. Speaking of good books about Richard Feynman’s adventures, Tuva or Bust by Ralph Leighton. It is one of the best books I have read out of the hundreds I have read.

Now that there is no more above ground testing. The best I can do is visit the  National Museum of Nuclear Science & History in Albuquerque, NM and the Bradbury Science Museum a window into the Los Alamos National Laboratory in NM. The Bradbury Musuem was seen in one of the early episodes of Breaking Bad as a meet up spot. After these museums, it would only be appropriate to drive up to Santa Fe and visit art museums as well, being just a short drive away. Someday I will make it to beautiful New Mexico and see the sights.

Richard Feynman TED talk

TED has a series of videos that feature Richard Feynman. In these videos he takes normal everyday things that we take for granted and explores them using science to bring out aspects that we may not have thought of. He does it in a way that makes it understandable for anyone. This talk is a stitched together series of short video interviews that essential is a posthumous TED talk featuring Richard Feynman.

Richard Feynman TED talk

Atomic Art

As an aside, I have actually done art that features an atomic bomb. This is why I would be interested in both the nuclear museums and the art museums in New Mexico! This piece represents the style of art that I have taken a liking to working in. I start in pencil and sometimes even thickening and darkening the work with pen or marker. Then I scan the piece in and work on the color and detail of bringing in different elements such as the background by using the GIMP editor. Essentially the piece is made up of different parts that are merged together in a final image. The sky, tower and ground were all created independently and merged.

 

Atomic Bomb Test Tower
Atomic Bomb Test Tower

Server Hardware Swaps

RAM Upgrade

When I initially built the server using a Dell Dimension 4200, I added 1GB of RAM on top of the 512MB that was factory installed. The board can support up to 2GB, but 1.5GB seems sufficient for what I am doing. One of the first steps is to run MEMTEST by booting off of a Linux CD that I had laying around. This test ran overnight (15+ hours) with no problems, it’s always a good idea to run MEMTEST with any memory changes.

Memory upgrade, added 1GB stick to the exiting 512MB
Memory upgrade, added 1GB stick to the exiting 512MB
Running MEMTEST to check for flaws in the RAM, before loading Ubuntu Server
Running MEMTEST to check for flaws in the RAM, before loading Ubuntu Server

 

 

 

 

 

 

 

 

 

 

 

Second Hard Drive
HD in floppy bay. Tight a bit tough getting the screws in.
HD in floppy bay. Tight, a bit tough getting the screws into the holder.
Pulled lower CD burner, replaced with DVD drive
Pulled lower CD burner, replaced with DVD drive
DVD drive goes in bottom slot, ready to load Ubuntu 12.04
DVD drive goes in bottom slot, ready to load Ubuntu 12.04

I removed the floppy drive and added a second 120GB hard drive. I also replaced one of the CD drives with a DVD reader. Ubuntu Server 12.04 gets burned onto a DVD so I needed to boot off of the DVD. The other option would be to boot from a USB drive. I swapped the IDE connector off of one of the CD drives and used it for the secondary hard drive mounted in the floppy drive bay.

Disconnected CD drive, hooked IDE HD in same bus as DVD drive.
Disconnected CD drive, hooked IDE HD in same bus as DVD drive.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Swap 120GB hard drive for 500GB

I soon was well on my way to filling up the primary 200GB drive so it was time to consider putting in a bigger secondary hard drive in preparation for the future.

I have installed the 500gb drive in the server and formatted for use with Linux. Linux can use a drive formatted as NTFS but I formatted it as EXT4 for Linux so the disk checks and fixes can be more precise. EXT4 can handle extremely large drives 1EB partition size, an amount of data I cannot even imagine! EXT3 is good up to 32TB partitions, which is still very big! The new extra drive will give me much more space as the main 200gb drive is almost full. I will move some files onto it, mostly the backups from the other computers at home. This is primarily the goal with second drive. There is a software manger in Linux that can manage the drive, so called “Logical Volume Management” (LVM), the primary drive is managed using this feature. In theory I can create a “snapshot” of the drive and copy the image onto a backup external or the second drive, but I have not considered doing this yet. The primary drive contains the OS, whatever software I have loaded, which doesn’t take up much space. The files that I have loaded onto OwnCloud take up a good deal of space, but 200GB will be plenty of space for the primary drive for a while.

To LVM or not?

At first I was going to connect the first and second drive into one large “logical” drive using LVM. But, there is a risk if the system treats the 500gb+200gb = 700gb logical drive. If one drive fails it can ruin the entire “logical” drive composed of both drives. One disk failing out of two might be a bad risk, so I might leave the drives connected normally, mounted separately and not as a big logical drive.

500GB drive mounted in the floppy drive holder
500GB drive mounted in the floppy drive holder
120GB drive out and 500GB drive in
120GB drive out and 500GB drive in
Resources

For more information on Linux file systems…

https://help.ubuntu.com/community/LinuxFilesystemsExplained

About files and the file system…

http://www.tldp.org/LDP/intro-linux/html/chap_03.html

 

 

 

 

Bread Dough Rising Time Lapse GIF

I do a lot of baking of fresh home made bread and I play around with time lapse photography from time to time. It seemed natural to put together a time lapse video of bread dough rising.

How it was done

I have used the Fire Storm fswebcam program for Linux to trigger web-cams to take periodic frames to monitor my house when I was away last winter. By being able to take periodic frames, fswebcam also makes it easy to do time lapse photography.

Basically for this GIF animation, the camera is triggered 10 times per hour. I run it under Linux using a Bash shell script that  time and date stamps the images when they are saved and creates folders based on the date. Then I open up the GIMP graphics editor and use File-> Open as Layers to bring all the images in, 140 in this case.  Then Filters-> Animation->Optimize (for GIF) creates the animation. I then save it as a GIF with 100ms delay between frames and allow looping. I did find another way to create videos found under the section How To Make a movie, under the section that talks about doing it via SSH on the Raspberry Pi, on the site, How To Capture Time-Lapse Photography With Your Raspberry Pi and DSLR or USB Webcam

Bread Dough Rising Animated GIF
Bread Dough Rising Animated GIF
 Bread Dough

The bread dough is a standard type of dough that I use often. It starts with 100g water and 100g white unbleached flour with a pinch f yeast as a poolish. This is left in a container overnight. Then 2 cups of flour, approximately 10 grams of salt and another pinch of yeast are added and thoroughly mixed. Water is added to the poolish, I start with about 1/2 cup. It is all mixed together adding more water if needed. It forms a dough ball that is worked for 1-2 minutes. Then I let it sit for 15 minutes. Water is contained in the starch bonds, this water is released during the working of the dough, it has a bit of a time delay and it will release even more water for a while after it has been worked. Allowing it to rest for 15-30 minutes allows the water to come out of the bonds and at that point you can judge whether or not the proper amount of water/flour ratio exists by the feel. Then I let the dough rise in a bowl that was coated with olive oil. My standard practice would not dictate letting it rise in open air overnight, effectively this dough has over proofed, but to take the pictures, I decide to just let it go and do it’s thing. Normally, it would be punched down a few times and if I am not ready to make it, it might go in the fridge overnight.

How did it come out by just letting it go and rise on it’s own? Surprisingly  the end product was OK, I actually baked it as in the Pyrex bowl and it was a fairly good bread after all. Baked at 400 F for about 40 minutes. I preheated the oven with small bowls of water in it to add moisture as well, leaving them in while the bread baked. This enhances the crust of the bread.

Technical details on capturing the frames

fswebcam

I used Fswebcam to capture the images. It has to be compiled from the source code. Below are my notes related to fswebcam. I had a bit of a hard time getting it to run last year, but the essence of what I had to do is captured below.

————————————————————————————
fswebcam – Small and simple webcam software for *nix.

Created by Philip Heron <philATCHARACTERsanslogic.co.uk>
http://www.sanslogic.co.uk/fswebcam/

This is the program used to generate images for a webcam. It captures a number
of frames from any V4L or V4L2 compatible device, averages them to reduce noise
and draws the details on it using the GD Graphics Library which also handles
compressing the image to PNG or JPEG.

Installing fswebcam
sudo apt-get install fswebcam

Alternatively install via the DEB packages below if you want a newer version that apt can install, especially if it installs the 2009 version, which it will do if you are using an older version of Ubuntu Linux. Try the latest one that will work, I was able to get a new version that did not complain about missing packages.

DEB packages, try one of these first

I first ran fswebcam on Ubuntu 10.04 and ran into issue with an old webcam (Using palette SGRBG8 was not supported and I got an unsupported palette error), plus all of the features advertised for the fswebcam such as labeling the photos and printing a time stamp on them was not working. It was probably in the works and didn’t make it into the release, or something on my installation was not supporting the label adding feature. But I was able to get the 20101118 installed via a DEB package above.

If using dpkg to install one of the deb packages fails. Or in the case you want to work through compiling this code, follow the guidelines below, which do not cover all cases.

I did compile from scratch years ago to get a newer version of fswebcam installed, beyond what the package manager would install. I have found out that dpkg will install version 20101118 on Ubuntu 10.04 without complaint. Beyond that version, dpkg will complain about missing dependencies. I was able to compile the version labelled 20110707 and that ran on 10.04. If you need to find the version of fswebcam use….

fswebcam --version

The versions currently run to 20140113, trusty release, as of 11/26/2014.

 

Installing GD Library, do this before installing fswebcam

This part gave a bit of a hard time as my notes below state that there was a few failed attempts to get fswebcam up and running.

sudo apt-get install libgd2-xpm-dev
 ./configure --prefix=/usr
 make
 sudo make install

NOT SURE IF THIS IS NEEDED

But I actually tried this first, instead of the command sequence above…
Downloaded libgd-2.1.0
cd to the libgd-2.1.0 directory
then ran…

./configure
 make
 sudo make install

Then tried to compile fswebcam again and it complained about missing JPEG GD package, so did  the compile again for GD with this command sequence instead…

./configure --with-jpeg --with-png --with-freetype
 make clean
 make
 sudo make install

FAILED

Tried this…

install php-gd

FAILED

So I think the first method of config,make,install of libgd2-xpm-dev is the one to try, first!
I only put the failed stuff here because I am not sure if doing the failed stuff first put in JPG, freetype or something that made things work once ibgd2-xpm-dev was loaded in.

Compile and Install fswebcam

Download the source code from http://www.sanslogic.co.uk/fswebcam/ and unzip in a directory named something useful under you home folder. Use tar to extract it.

tar xvzf fswebcam-DATECODE.tar.gz

Best to use sudo make install so that the files wind up being able to be put where they need to be.

Run the following commands in the source folder to build and install fswebcam:

./configure --prefix=/usr
 make
 make install

It’s only requirements are that the GD library be installed with JPEG, PNG
and FreeType support.

Checking to see if the webcam is being read by the PC

Command to see what devices are hooked up to the USB for video…

ls /dev/video*

There is also a porgram called Cheese that can be installed via the package installer for Ubuntu. This lets you see the video live from the web cam. It makes it easy to adjust distance, angles, lighting and focus the cam while setting up the shot.

Autocam/Breadcam

I created autocam.sh to be called by watch periodically in order to snap a photo, name it the yr,month,day:time.jpg and put it in a created folder label for the date. Then I used to copy to Wuala mirrored path, which would automatically load it onto a Wuala cloud drive. The script below has the Wuala stuff ripped out. At the bottom of this post there is an explanation on how to use Wuala as an NFS drive.

For example, call bash script every 10 seconds…

watch -n 10 bash autocam.sh

Remember to chmod u+x autocam.sh so that it can be made into an executable script.

Autocam.sh code
#!/bin/bash
# this is the command to run this with watch -n 3579 bash autocam.sh for hourly rate at 255 frames to image
 # this is the command to run this with watch -n 350 bash autocam.sh for 10x hourly rate
# /%Y%m%d/hour-%H/%Y-%m-%d-%H:%M:%S
#now is the filename for the date stamped jpg file
 now=$(date +"%Y-%m-%d-%H:%M:%S")
#dir is the directory that is dated as the date of the picture. I need an IF statement around this so it doesn't keep creating the same dir.
 dir=$(date +"%Y%m%d")
mkdir $dir
#pathnow, I don't think is needed anymore.
pathnow=$(date +"%Y%m%d")
#filename="webcam.$now.jpg"
#filename="$now.jpg"
 # example filename: my_program.2012-01-23-47.log
#fswebcam  -S 15 --flip h --jpeg 90 --shadow --title "erick cam" --subtitle "Home" --info "Monitor: Active @ 1 fph" --save $now.jpg  --device  /dev/video0
 fswebcam  -S 15 --jpeg 90 --shadow --title "erick webcam" --subtitle "Dough Rising" --info "Monitor: Active @ 10 fph" --save $now.jpg  --device /dev/video0 -F 50
# Copy cam pic to file that the FTP program will send to the frontiernet.net site.
 cp $now.jpg cam1.jpg
#move local copy to local directory only and copy for FTP!
 mv $now.jpg $dir
#put on website to embed into page
HOST='ftp.ftplocation.net'
 USER='xxxxxxxxx'
 PASSWD='xxxxxxxx'
 FILE='cam1.jpg'
ftp -n $HOST <<END_SCRIPT
 quote USER $USER
 quote PASS $PASSWD
 cd public_html
 put $FILE
 quit
 END_SCRIPT

 

Wuala

I was saving the pictures onto a Wuala cloud drive when I originally developed the autocam.sh script.

Might need this package so that Wuala can map as an NFS drive…

sudo apt-get install portmap nfs-common

Location of Wuala drive as it created by default…

/home/erick/WualaDrive



 

 Resources

Ubuntu Man Page for fswebcam

fswebcam web page

Webcam capture using fswebcam

Shows how-to install fswebcam via package installer, I have not tried this…

http://www.8devices.com/wiki_carambola/doku.php/carambola_fswebcam

To make a movie via the Linux Command line, go to the section on How To Make a movie, under the section that talks about doing it via SSH on the Raspberry Pi, on the site…

How To Capture Time-Lapse Photography With Your Raspberry Pi and DSLR or USB Webcam

From Some fun with a webcam , I like how the code to run the camera has it set the font as white against a transparent footer. The code in bold makes it happen…

Excerpt…

width=640
height=480

…………….

exec fswebcam –quiet –skip 14 \
–font $font \–timestamp ‘%d %b %y %H:%M:%S (%Z)’ \
–no-title -r $height\x$width \
–banner-colour ‘#FF000000’ \
–line-colour ‘#FF000000’ \
–exec $capture \
–loop $interval $output

—————

 

Very cool, a portable time lapse camera using a Raspberry Pi and a battery, stuffed in a tin can. This is the way to go!

Simple timelapse camera using Raspberry Pi and a coffee tin

 

You are NOT a Software Engineer

Below is a link to a great post that is dead on. I used to think about the fact that software engineering doesn’t follow the same work pattern as engineering physical things when I worked in industry. People get the idea that you can schedule software projects when it is more like forecasting. I liken it to the tides versus the weather, you can schedule plans around the tides, years in advance, as there are actual schedules of the tides, a.k.a. Tide Tables,  not so with regard to the weather.
You don’t always know where things will be at a certain point in the future. Predicting things a few days out OK, trying to plan a software project grandiose style 6 months ahead and know where it is going to land, is like trying to make plans around a sunny and 72 degree July 4h BBQ, but trying to figure out that probability in January!

Chris Aitchison, says what I was thinking for years, but much better than I could have put it….

www.chrisaitchison.com/2011/05/03/you-are-not-a-software-engineer/

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

CD recording from the Linux command line using cdrdao

I’ve been interested in a way to burn right from the command line, with a possibility of using one of my Linux computers with a mode as a burn station, ideally I could throw in a CD, it would detect it and start the copy process and eject when done. This post is about a small step in that direction.

I researched it a bit and tried the example given by this page….

https://help.ubuntu.com/community/cdrdao

But, I modded the  $HOME/.cdrdao file a bit to include a list of cddb servers that I pulled off of,http://roozster.info/eac/06.html,  plus added a timeout for the cddb set to 10 seconds.

The .cdrdao file goes in your home directory and it acts like a configuration file for the cdrdao program. The help site above goes into details. But, briefly the write buffer at 128, which is 128 seconds, at an 8x burn gives 16 seconds of under-run protection. The device has to be set correctly. My CD burner is at /dev/sr0. According to the help.ubuntu site above, running sudo cdrdao scanbus, will produce an output that yields the device name. For me it didn’t yield a /dev type of connection but rather a 1,0,0 bus attachment type of readout. But I hovered over the CD in the file manager and found out the device mount point from there which was /dev/sr0.

Output from running sudo cdrdao scanbus
Cdrdao version 1.2.2 - (C) Andreas Mueller <andreas@daneb.de>
  SCSI interface library - (C) Joerg Schilling
  Paranoia DAE library - (C) Monty

Check http://cdrdao.sourceforge.net/drives.html#dt for current driver tables.

Using libscg version 'ubuntu-0.8ubuntu1'

1,0,0 : QSI     , CDRW/DVD SBW-242, UD22

Paranoia Mode

Paranoia mode is interesting as it provides some repair of the ripped audio, from http://www.linuxcommand.org/man_pages/cdrdao1.html

--paranoia-mode mode
              Sets the correction mode for digital audio  extraction.  

0:  No checking,  data  is  copied  directly from the drive.
1: Perform overlapped reading to avoid jitter. 
2: Like  1  but  with  addi-tional  checks  of the read audio data. 3: Like 2 but with addi-tional scratch detection and repair.


              The extraction speed reduces from 0 to 3.

Below is the code that I pull from the site and modded by adding the cddb_servers and cddb_timeout this code is used to create  the $HOME/.cdrdao file

#---$HOME/.cdrdao --#
write_buffers: 128
write_device: "/dev/sr0"
write_driver: "generic-mmc"
read_device: "/dev/sr0"
read_driver: "generic-mmc"
read_paranoia_mode: 3
write_speed: 8
cddb_servers: "http://cddb.cddb.com:80/~cddb/cddb.cgi","http://sc.ca.us.cddb.com:80/~cddb/cddb.cgi","http://sc2.ca.us.cddb.com:80/~cddb/cddb.cgi","http://sj.ca.us.cddb.com:80/~cddb/cddb.cgi","http://sj2.ca.us.cddb.com:80/~cddb/cddb.cgi","http://us.cddb.com:80/~cddb/cddb.cgi"
cddb_timeout: 10
 A few good command line options for cdrdao

I also fire the cdrdao command with the options –with-cddb to include the text info onto the burned CD and –eject to eject the CD on a completed burn.

sudo cdrdao copy --with-cddb --eject

This code can be put in a bash script. I created cdcopy.sh to make it simple to fire off from the command line.

Download as cdcopy.sh.txt -> cdcopy.sh

Rename cdcopy.sh.txt to cdcopy.sh, put in home and run chmod 755 on it to make it executable

chmod 755 cdcopy.sh

 

So far I have used this method to burn about 10 CD’s in the first week I finished trying this and tested them out in a CD player and ripped them both with Media Player and iTunes, all worked well!