How to install nmap / netcat on Boot2Docker

boot2docker uses tinycorelinux ( tiny core linux ) for it’s base image – and it is just that – tiny.

If you want to add in utilities, you’ll need to use tce-load because this distro doesn’t have apt-get install / aptitude install or yum install

What they have instead is tce-load – some information can be found on their install apps page

To install nmap you can run:

tce-load -wi nmap.tcz

I did not see netcat listed on the packages page but I was able to install socat which does the same things as netcat

tce-load -wi socat.tcz
Posted in Linux | Leave a comment

Build Pianobar from Source on Raspberry Pi Raspbian

After getting the TLS handshake Error from pianobar on Raspberry Pi running Debian Wheezy ( aka Raspbian ) I decided to get the latest version of Pianobar. This requires building from sourcecode if you’re on the Wheezy release.

The TLS handshake Error can basically be translated to mean “the version of pianobar you’re using is too old” – this is an error that occurs regularly and the solution is always to update to the latest edge version. Packges for Raspbian / Wheezy aren’t going to get updates fast enough for this to be a good option (i.e. to not interrupt your listening ) so you’ll need to build from source.

One of the requirements is basically to have ffmpeg ( it the libraries from it ) installed. Several people will suggest installing ffmpeg from source – which you can do – but if you’re using a “Raspberry Pi model B” and not the latest Raspberry Pi 2.0 – or even if you are – it will take a long time to build ffmpeg from source – maybe 6 hours or more.

If you go this route, and you’re doing it via SSH make sure to use something like screen to keep the process from dying if you get disconnected.

I didn’t want to install ffmpeg and found a good alternative – install the libraries from the backports.

Here’s a script – which is basically my notes from along the way. It is sloppy and has some duplication – created from trial and error – but it worked for me and the duplicate packages is not an issue with apt-get ( if one of them is already installed it will be skipped)

So, run as root or with sudo. Good luck – report issues on the PromyLOPh github page, or leave a comment if you have any adjustments or tweaks or improvements to the script.

#!/bin/bash

# script from https://techblog.willshouse.com/?p=5564
# based on notes from:
# http://www.mobileread.com/forums/archive/index.php/t-224800.html


apt-get install -y debian-keyring debian-archive-keyring

if [[ "`grep -c wheezy-backports /etc/apt/sources.list`" -lt 1 ]]; then
 echo deb http://ftp.us.debian.org/debian wheezy-backports main contrib non-free >> /etc/apt/sources.list
 echo deb-src http://ftp.us.debian.org/debian wheezy-backports main contrib non-free >> /etc/apt/sources.list
fi

apt-get update

apt-get install -y git libao-dev libgcrypt11-dev libgnutls-dev libfaad-dev libmad0-dev libjson0-dev make pkg-config libevent-pthreads-2.0-5 libao-dev gnutls-dev libmad0-dev libfaad-dev libjson0-dev pkg-config git libao-dev libgcrypt11-dev libgnutls-dev libfaad-dev libmad0-dev libjson0-dev make pkg-config
apt-get install -y libgnutls28-dev
apt-get -t wheezy-backports install libavfilter-dev libavformat-dev libswscale-dev libavresample-dev -y
apt-get -t wheezy-backports install libavfilter-dev libavformat-dev libswscale-dev libavresample-dev libgnutls28-dev -y

apt-get install libavcodec-dev libavfilter-dev libavformat-dev alsa-utils -y

apt-get install -y alsa-utils

# may need to make sure this module is loaded at startup:
sudo modprobe snd_bcm2835


cd /usr/src
git clone https://github.com/PromyLOPh/pianobar.git
cd pianobar
make
make install
Posted in Software | Tagged , | Leave a comment

Connect to Lantronix Spider from Ubuntu RS232 Serial Port or USB

If you need to connect to the Lantronix Spider or SpiderDuo KVM-over-IP Devices via a serial connection, for example to change the configuration or reset the password, you need to use a serial console to do this.

I was using an Ubuntu machine with a standard serial / com port ( DB9/RS232 ) and had one of the $4 RJ45 to DB9/RS232 cables

To get connected I ended up installing picocom which I like better than using screen as it seems to be more forgiving if something goes wrong and not lock up the system.

Then I used the command picocom -b 9600 /dev/ttyS0 to connect to the device and got prompt so I could reset the device:

Welcome!
Choose a command for the following features:
-Initial IP configuration: "config".
-Reset device: "reset".
[(none) spider]>

If you don’t have a RS232 you can also use a ~ $10 USB to RS-232 DB9 Serial Converter in order to get a serial port.

The device will show up in /dev/ as something like /dev/ttyUSB0 which will change your picocom command to be:

picocom -b 9600 /dev/ttyS0

To exit picocom use control+a, control+x.

To install picocom on Ubuntu / Debian linux systems use apt-get install -y picocom


A few notes from the Lantronix page:

How do I perform the reset?

See details on the lantronix page – you will need to use the reset button on the back of the device in combination with a terminal connection described above.

What is the default password?

Try logging in with the default username, sysadmin, and password, PASS

If that does not work, please use the procedure near the top of page 121 of the Spider User Guide

I forgot my password. How can I reset the Spider to factory defaults?

Use the serial interface with a terminal emulator program set to 9600 or 115200, 8 bit characters, No parity, 1 Stop bit, and No flow control. Within 2 seconds of booting the Spider, press the Esc key a few times to get a => prompt. Type defaults at the => prompt.

If you can’t get the => prompt after several tries at 9600, try 115200. Earlier firmware sets the serial console port to 115200 by default.

Posted in Server Admin | Tagged , | Leave a comment

hombrew: brew install gxargs

The xargs utility on Mac is not the same as the one on linux. In particular, searching for files with the mdfind utility will not properly escape files to be processed.

Using homebrew you can install the GNU version of xargs as gxargs, and you can use the syntax you’re accustomed to from GNU/Linux.

For me this is equivalent to something like:

mdfind -name "conflicted copy" | gxargs -d '\n' -P 4 echo

To remove the files you can then replace echo with rm – but be careful!

Posted in Mac | Tagged , | Leave a comment

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

When recently using Intel Active Management Technology (AMT) I was remotely connected via the RealVNC client, but was having trouble sending keystrokes like F2 to enter the BIOS, F12 to select a startup device, or F8 to access the Windows startup menu.

This setup is complicated for a few reasons – first I’m using a Mac keyboard. Secondly, OS X remaps the function keys to do things like dashboard, expose, brightness, and volume by default.

After a little searching and trial and error, I found that I can use the free utility included with Mac OS X – AppleScript Editor.app – to send keycodes to the VNC connection. Here’s the code for the applescript you can use to send the F12 key:

tell application "VNC Viewer"
  activate
  tell application "System Events" to key code 111
end tell

This is what it should look like in the editor:

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

To send key combos, like holding down alt and pressing F4, the syntax would be something like this:

tell application "System Events" to key code 118 using {command down}

We use command instead of alt because that is how Real VNC Viewer translates the “alt” key for a remote windows system by default.

To send other keyboard F-keys to the remote Windows machine, use the table below to find the appropriate key – make sure to reference the “Mac” column even if the remote machine is a Windows box.

What about JAVA?

But what happens if you are running a java applet for a KVM console? How do you tell java to do a keycode?

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

To tell java to send F12 try this:

tell application "System Events" to set frontmost of process "java" to true
tell application "System Events"
    tell process "java"
        key code 111
    end tell
end tell
KeyMacWindowsLinuxNotes
KeyUp12626103
KeyDown12528108
KeyLeft12325105
KeyRight12427106
KeyBackspace117814
KeyEnter76*28
KeyHome11536102
KeyEnd11935107
KeyPageDown12134109
KeyPageUp11633104
KeyReturn3613*
KeyDelete5146111
KeyTab48915
KeySpacebar492057
KeyShift5610*
KeyControl5911*
KeyMenu5818139The Alt key
KeyPrintScreen*42210
KeyEscape53271
KeyCapsLock572058
KeyHelp11447138
KeyF112211259
KeyF212011360
KeyF39911461
KeyF411811562
KeyF59611663
KeyF69711764
KeyF79811865
KeyF810011966
KeyF910112067
KeyF1010912168
KeyF1110312287
KeyF1211112388
KeyMacFn63**
KeyMacOption58**
KeyMacCommand55**
KeyWinLeftWindow*91*On "Natural" keyboards
KeyWinRightWindow*92*On "Natural" keyboards
KeyWinApplication11093*On "Natural" keyboards
KeyQ128116
KeyW138717
KeyE146918
KeyR158219
KeyT178420
KeyY168921
KeyU328522
KeyI347323
KeyO317924
KeyP358025
KeyA*6530
KeyS18331
KeyD26832
rbKeyF37033
KeyG57134
KeyH47235
KeyJ387436
KeyK407537
KeyL377638
KeyZ69044
KeyX78845
KeyC86746
KeyV98647
KeyB116648
KeyN457849
KeyM467750
Key0294811
Key118492
Key219503
Key320514
Key421525
Key523536
Key622547
Key726558
Key828569
Key9255710
KeyPeriod4719052
KeyComma4318851
KeySlash4419153The key with /? generally next to right shift key.
KeyNum0829682On numeric keypad or with NumLock
KeyNum1839779On numeric keypad or with NumLock
KeyNum2849880On numeric keypad or with NumLock
KeyNum3859981On numeric keypad or with NumLock
KeyNum48610075On numeric keypad or with NumLock
KeyNum58710176On numeric keypad or with NumLock
KeyNum68810277On numeric keypad or with NumLock
KeyNum78910371On numeric keypad or with NumLock
KeyNum89110472On numeric keypad or with NumLock
KeyNum99210573On numeric keypad or with NumLock
KeyMultiply6710655On numeric keypad or with NumLock
KeyAdd6910778On numeric keypad or with NumLock
KeySubtract7810974On numeric keypad or with NumLock
KeyDivide7511198On numeric keypad or with NumLock
KeyDecimal6511083On numeric keypad or with NumLock
KeyNumEqual81*117On numeric keypad or with NumLock

If you haven’t seen Intel’s AMT with KVM control – check it out. They say, “with out-of-band management capabilities, including Keyboard-Video-Mouse (KVM) Remote Control,3 Intel AMT allows IT to remotely remediate and recover systems after OS failures. Out-of-band alerting and event logging also help to reduce downtime,” and basically it just makes it really easy to connect to a computer to control it – even access the BIOS etc before it even boots into windows.

How to send F2, F8, F9, F12 to a VNC Remote PC from Mac OS X

Posted in Tech Tips | Tagged , , , | Leave a comment

How to set the Date & Time for photos and videos taken with a Quadcopter such as the Dromida Kodo

If you’ve taken photos and videos with the a RC Quad Copter such as the Dromida Kodo, the X5C, or one of the many Quad Copters sold on Amazon you may have noticed that when you get finished taking photos and videos you have a result like this:

Oct  1 01:03:40 2013 MOVI0000.avi
Oct  1 01:04:04 2013 MOVI0001.avi
Oct  1 01:04:20 2013 MOVI0002.avi
Oct  1 01:04:20 2013 MOVI0003.avi

Oct  1 01:00:52 2013 PICT0000.jpg
Oct  1 01:00:56 2013 PICT0001.jpg
Oct  1 01:04:08 2013 PICT0002.jpg
Oct  1 01:04:12 2013 PICT0003.jpg

All of the dates and times seem to be on October 1, 2013 shortly after 1:00.

How to set the Date & Time for photos and videos taken with a Quadcopter such as the Dromida Kodo

To get the correct timestamps, you can save a file to the SD card named time.txt with the date in the format “yyyy/mm/dd hh.mm.ss”

Use notepad or another text editor to create the file, and name it time.txt with the timestamp all on one line, and then a newline (press ‘enter’) after it. This will be used to set the camera’s clock as long as it has power.

Here are some examples for different timezones – and you can also download files with the current timestamps:

Eastern (EDT) - download current time.txt for Eastern (EDT)
2015/08/31 15.47.08
Central (CDT) - download current time.txt for Central (CDT)
2015/08/31 14.47.08
Mountain (MDT) - download current time.txt for Mountain (MDT)
2015/08/31 13.47.08
Mountain no DST - download current time.txt for Mountain no DST
2015/08/31 12.47.08
Pacific (PDT) - download current time.txt for Pacific (PDT)
2015/08/31 12.47.08
Alaska (ADT) - download current time.txt for Alaska (ADT)
2015/08/31 11.47.08
Hawaii (HDT) - download current time.txt for Hawaii (HDT)
2015/08/31 10.47.08
Hawaii no DST - download current time.txt for Hawaii no DST
2015/08/31 09.47.08
Posted in Uncategorized | Leave a comment

How to tell if PL-2303HX ( PL-2303 ) is 3.3v or 5v

If you have a USB adapter and would like to use it when working with Arduino or Raspberry Pi you may wonder if it is safe to use with a 3v3 system.

Purchasing these on eBay can be cheaper than buying from someplace like Adafruit but the listings often have no documentation on if the chip can be used with 3.3v devices.

You can measure some of the pins to make your own determination. The unit I was working with several pins labeled:

How to tell if PL-2303HX ( PL-2303 ) is 3.3v or 5v

I measured voltage between the GND pin and the TX pin which gave around 1.8 – 2.5V without any data being transmitted. When I sent data to the device the voltages went intermittently to around 3.3 volts or maybe 3.4 volts.

But I wanted to make sure that the chip was actually setup for 3.3v and so I found the datasheet for the PL-2303HX

Make sure to get the correct datasheet for the chip you have – some of the chips are slightly different, like the HXD version.

On page 11 of that datasheet it showed the pinout diagram – notice the small circle indicating “pin 1” which should correspond to the small dot on the actual chip:

How to tell if PL-2303HX ( PL-2303 ) is 3.3v or 5v

Pin 4 is labeled VDD_325 and the note says:

RS232 VDD. The power pin for the serial port signals. When the serial port is 3.3V, this should be 3.3V. When the serial port is 2.5V, this should be 2.5V. The range can be from 1.8V~3.3V.

Use this information at your own risk, but what I believe this datasheet is expressing is that if pin4 measures 3.3V then the TX pin will transmit using 3.3V and if it is 5V then it will transmit using 5V.

When I measured pin4 on my PL-2303HX it showed 3.3V and I was able to use it with a raspberry pi with no problems.

Posted in Linux | Tagged , , | Leave a comment

How to use http_build_url with pecl_http version 2.0 with PHP 5.4, 5.5, and 5.6

The old way to use http_build_url

This is how to use http_build_url with pecl_http version 1.x:

$parse = parse_url('http://example.com/index.asp?test=123#hash');

print_r($parse);
#
# Yields a result of:
#
# Array
# (
#     [scheme] => http
#     [host] => example.com
#     [path] => /index.asp
#     [query] => test=123
#     [fragment] => hash
# )

$url = http_build_url($parse);
echo $url;
#
# Yields a result of:
#
# http://example.com/index.asp?test=123#hash

The new way to use http_build_url with pecl_http version 2.x:

This functionality has now moved into the http\Url class:

$parse = parse_url('http://example.com/index.asp?test=123#hash');

print_r($parse);
#
# Yields a result of:
#
# Array
# (
#     [scheme] => http
#     [host] => example.com
#     [path] => /index.asp
#     [query] => test=123
#     [fragment] => hash
# )

$url = new \http\Url($parse);
echo $url->toString();
#
# Yields a result of:
#
# http://example.com/index.asp?test=123#hash
#
Posted in Tech Tips | Tagged , | Leave a comment

Solved: linphone: error: libupnp >= 1.6 < 1.5 required.

If when attempting to compile linphone you get this error when running ./configure –

 error: libupnp >= 1.6 < 1.5 required.

Then you can try what L Miller suggests and do:

apt-get remove libupnp4-dev

And then:

apt-get install libupnp6-dev

This seems to do the trick when compiling on Ubuntu 14.04.

After upgrading this library I started over in the compiling instructions with autogen:

- Compile linphone

 $ ./autogen.sh
 $ ./configure 
 $ make && sudo make install 
 $ sudo ldconfig

If that still doesn’t work then see http://akh1.blogspot.hk/2014/04/compiling-linphone-37-in-ubuntu.html

Posted in Linux, Software | Tagged , | Leave a comment

How to disable the LEDs on the PogoPlug running Debian Squeeze

How to disable the LEDs on the PogoPlug running Debian Squeeze If you’ve installed Debian Squeeze on the PogoPlug you’ll notice there is no longer an /sys/module/xce/sections/ or /dev/xce path for you to echo commands to. However, you can still control the LEDs by using the sys -> devices -> platform -> LEDS / GPIO

How to disable the LEDs

echo 0 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness
echo 0 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness

How to make the LED green

echo 0 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness
echo 1 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness

How to make the LED red

echo 1 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness
echo 0 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness

How to make the LED orange / yellow

echo 1 > /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness
echo 1 > /sys/devices/platform/leds-gpio/leds/status:green:health/brightness

You can also try using values 1-255 to control the brightness but I didn’t see much difference between different numbers. ymmv.

Also, if you wish to read the status of the LEDs you can do so by using something like cat with these paths:

cat /sys/devices/platform/leds-gpio/leds/status:red:fault/brightness

A value of 0 indicates the LED is off.

Most likely if you are running Debian there will be no events that turn the LEDs on – but in case you have issues you can disable system events from triggering the LEDS you also need to change the ‘triggers’ – first check out the existing ones:

 cat /sys/devices/platform/leds-gpio/leds/status:green:health/trigger

This results in:

 [none] nand-disk timer oneshot ide-disk1 ide-disk2 heartbeat gpio default-on mmc0

And for the red led use:

 cat /sys/devices/platform/leds-gpio/leds/status:red:fault/trigger

Which should result in:

 [none] nand-disk timer oneshot ide-disk1 ide-disk2 heartbeat gpio default-on mmc0

Next, to disable the events from triggering the LEDs run:

 echo none > /sys/devices/platform/leds-gpio/leds/status:green:health/trigger
 echo none > /sys/devices/platform/leds-gpio/leds/status:red:fault/trigger
Posted in Server Admin, Tech Tips | Tagged , | Leave a comment