skanc.com Linux, Microsoft, Raspberry Pi, Python, Android

22Aug/121

Raspberry Pi – Tips & Tricks 9 – Sending External IP To via Gmail

nano external_ip
------------------------------------------------------------------------------------------------------
import urllib
import smtplib
import re

#External IP Address
f = urllib.urlopen("http://www.canyouseeme.org/")
html_doc = f.read()
f.close()
m = re.search('(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-

5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',html_doc)
#print m.group(0)
data=m.group()

#Mail send
fromaddr = 'youraccount@gmail.com'
toaddrs  = ['test@gmail.com']
msg = 'Raspberry Pi External IP Addreds is ' + data + ' ...!'

# Credentials (if needed)
username = 'youraccount@gmail.com'
password = 'yourpassword'

# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
for toad in toaddrs:
    server.sendmail(fromaddr, toad, msg)
server.quit()
------------------------------------------------------------------------------------------------------

chmod a+x external_ip

20Aug/120

Raspberry Pi – Tips & Tricks 8 – Install Chromium browser

sudo apt-get install chromium-browser

20Aug/120

Raspberry Pi – Tips & Tricks 7 – Full backup & restore of the image

If you are running linux then you can use the dd command to make a full backup of the image:

dd if=/dev/sdx of=/path/to/image

or for compression:

dd if=/dev/sdx | gzip > /path/to/image.gz

Where sdx is your SD card.

To restore the backup you reverse the commands:

dd if=/path/to/image of=/dev/sdx

or when compressed:

gzip -dc /path/to/image.gz | dd of=/dev/sdx

20Aug/120

Raspberry Pi – Tips & Tricks 6 – USB drives mount

sudo tail -f /var/log/syslog&

and re-insert the usb device

sudo mount /dev/sda1 /mnt

20Aug/120

Raspberry Pi – Tips & Tricks 5 – Create a new user with sudo-privileges

sudo adduser username

sudo visudo
------------------------------------------------------------------
Add following line under the "root ALL=(ALL) ALL" Line:

yourUsername ALL=(ALL) ALL

------------------------------------------------------------------

20Aug/122

Raspberry Pi – Tips & Tricks 3 – Static IP Address and DNS Settings

IP Address Settings

sudo nano /etc/network/interface

 -------------------------------------------------------

auto lo

iface lo inet loopback

iface eth0 inet static

address 192.168.1.X

netmask 255.255.255.0

network 192.168.1.0

broadcast 192.168.1.254

gateway 192.168.1.X

 -------------------------------------------------------

 

DNS Settings

sudo nano /etc/resolv.conf

-------------------------------------------------------

nameserver 192.168.1.1

-------------------------------------------------------

Restart networking

sudo /etc/init.d/networking restart

or

sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start

or
sudo shutdown -r now

20Aug/120

Raspberry Pi – Tips & Tricks 2 – Keyboard Configuration

sudo raspi-config

or

sudo dpkg-reconfigure keyboard-configuration

or

sudo nano /etc/default/keyboard

XKBLAYOUT=”tr”

--------------------------------------------------------------
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc102"
XKBLAYOUT="tr"
XKBVARIANT="intl"
XKBOPTIONS=""

BACKSPACE="guess"
--------------------------------------------------------------

20Aug/120

Raspberry Pi – Tips & Tricks 1 – Configuration

sudo raspi-config

20Aug/120

Raspberry Pi – Quick Start Guide

1. Download the image from a mirror or torrent. Raspbian “wheezy” (2012-07-15-wheezy-raspbian.zip.torrent)

2. Extract the image file

3. Download the Win32DiskImager utility

4. Select the drive letter of the SD card in the device box, click write and wait for the complete

5. Exit the imager and eject the SD card

6. Insert the card in the Raspberry Pi, power it on, and it should boot up

20Aug/120

Raspberry Pi – You will need

1. Raspberry Pi - Model B Farnell element14
2. USB keyboard and mouse Logitech Wireless Combo MK320
3. 2 GB SD card SD Card
4. HDMI/composite cable or HDMI to DVI cable
5. Micro USB power supply capable of providing at least 700mA at 5V 5V 2000mA
6. USB to Micro USB Cable 2m (Raspberry Pi Power Supply) USB Cable 2m
7. New Link 4 Port USB Hub (USB 2.0 with Mains Adaptor) USB Hub
8. Ethernet cable