gtk dialogs in linux

Wednesday, December 05, 2007

Bash scripts are fantastic. I could end the post there, but they can be made even better for end users by using one of the simple GUI applications out there that can be run from bash. Here's a great little example (using gtkdialog)that pretties-up the interface for my infrared phone script from this post.

#! /bin/bash

OUTPUT=$(/usr/local/bin/phone-connect $1 | sed -e 's/\(.*\)$/


Beautiful

get connected with infrared device in linux

Using Ubuntu (known to work for Feisty and Gutsy), follow the instructions here. The only change to those instructions I needed to make was to set automatic="true' in irda-utils.

Then use the following script:

#! /bin/bash

# phone-connect. Copyright Brad Milne, 2007. Search for infrared phone
# and mount it using obexfs if available.

case "$1" in
start)
echo -n "Starting connection to phone..."

#first restart irda-utils if phone not visible
grep nickname /proc/net/irda/discovery > /dev/null
if [ $? -eq 0 ]; then
/etc/init.d/irda-utils restart > /dev/null
fi
obexfs -i /mnt/phone

if [ $? -eq 0 ]; then
PHONE=$(grep nickname /proc/net/irda/discovery | sed -e 's/nickname: //' | cut -d, -f1)
echo "Connected to $PHONE"
else
echo "Connection failed. Does phone have infrared turned on?"
fi
;;
stop)
# 'stop' I haven't yet been able to implement due to restrictions
# on unmounting the fuse device. For now I use 'sudo umount /mnt/phone'
echo -n "Stopping connection to phone..."
/bin/fusermount -u /mnt/phone/
if [ $? -eq 0 ]; then
echo "Done"
else
echo "Failed. Was it connected?"
fi
;;
status)
ifconfig irda0 | grep irda0 > /dev/null
if [ $? -eq 0 ]; then
echo "Infrared device is active"

grep nickname /proc/net/irda/discovery > /dev/null
if [ $? -eq 0 ]; then
PHONE=$(grep nickname /proc/net/irda/discovery | sed -e 's/nickname: //' | cut -d, -f1)
echo "Currently connected to phone"

if [ $(ls -l /mnt/phone | wc -l) -gt 1 ]; then
echo "Phone files accessible at /mnt/phone"
else
echo "Phone not mounted"
fi
else
echo "Not connected to phone"
fi
else
echo "Infrared device not active. Is infrared device plugged in?"
fi
;;
*)
echo "Usage: phone-connect {start|stop|status}"
;;
esac


Then to make it runnable by any user, do a chmod 4711 as described here, on the script itself, obexfs, irda-utils, and on fusermount (which needs to be readable by all users also).

router disconnecting from telstraclear?

Thursday, November 22, 2007

If you're in NZ, and you've got TelstraClear cable internet, congrats cos that's the best option we have.

But if you have the experience I've had, you'll be tearing your hair out. I have a couple of computers at home (only my wife's work laptop runs Windows :) and a Netgear router (WGR614 v7) connecting them to the cable modem. Since the first weeks of having the setup though, the internet connection drops off way too often (3-4 times in a work day). Telstraclear and the modem were fine; connecting just one computer direct to the modem would chug along for weeks without issues. I am on my second replacement router (that means 3rd in total) and have had conversations with Dick Smiths (router retailer) and Netgear, and still have the same problem.

Frustrations!

So today I managed to talk directly to the right people at TC to help me troubleshoot things. And lo! I have the wrong type of cable modem!!
That's right, they have two (at least) models they provide customers with, the Motorola SB5101 and 5100. I had been given the 5101, and not knowing there was an option, had blindly accepted it as the modem.

TelstraClear cable customers using a router should be provided a model 5100 cable modem.

If this is you, and you are having these problems then call them. They should replace it without a call-out fee if you had a router from the start. And how are we mere customers supposed to know this? Beat your head against various unyielding walls for a year seems to be the answer...

EDIT: Just had the modem replaced this morning. Turns out the 5101's were introduced to be more compatible with Windows XP! What a joke - you know not everyone uses Windows! And the 5100's won't fix the problem, but they should reduce the disconnects. The main cause is an issue with TC's hardware, for which they're getting in some new equipment which should resolve the issue by the end of February 2008.


Also, on the topic of things TC doesn't tell you about their cable internet service, they recently rolled out a 'customer security' measure whereby any change in MAC address connected directly to the modem will not work for a stand-down period of a number of hours. So if you change computers that are directly connected (or switch from router to computer while troubleshooting!) then you won't get a connection anyway. That took a bit of figuring out at the time. You have to ring them and ask for that 'feature' to be removed from your account. It does have security benefits, but it's a wired connection, so someone would have to be sneakily plugging into your modem or cable anyway.

Good service, but keep us informed Telstra.

tell apt your proxy settings

Thursday, October 11, 2007

Apt needs to be configured to use a proxy if you're using one (eg if using cntlm). This is done by creating /etc/apt/apt.conf.d/proxy, with content similar to:

Acquire {
Retries "0";
HTTP {
Proxy "http://127.0.0.1:3128";
};
};

Restore Grub

Tuesday, September 18, 2007

How to restore grub, the linux boot manager. Maybe a Windows installation has written over the MBR?

Use a boot disk, such as Knoppix or Ubuntu LiveCD.

1. $ sudo grub
2. grub> find /boot/grub/stage1
(If it fails here, jump to 'preparing root' below)
3. grub> root (hd#,#) (where 'hd#,#' is the result of step 2)
4. grub> setup (hd#)
5. grub> quit
That's it. Done!

-------------------------------------------------------------------------
Preparing root
If step 2 failed above then do these steps first:
A. $ sudo mkdir /mnt/root
B. $ sudo mount /dev/sda1 /mnt/root (where sda1 is your linux partition)
C. $ sudo mount -t proc none /mnt/root/proc
D. $ sudo mount -o bind /dev /mnt/root/dev
E. $ sudo chroot /mnt/root /bin/bash
Now start again from step 2 above.

Full credit to the guys on this thread at ubuntuforums.

log4j logging levels

Wednesday, September 12, 2007

  • FATAL
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE

From wikipedia site

Accessing ISA proxies in Linux

Monday, September 03, 2007

I was stuck trying to get through a MS Proxy Server. Thankfully people have magicked a way around it. Get NTLMaps and read these instructions, particularly note the dpkg-reconfigure line, it's easily missed.

EDIT: Wohoa! While NTLMaps is a great tool, it was using 130% of my dual-core 2GHz processor! Thankfully there is a much slicker alternative: cntlm. This puppy is C-based and has a much lower overhead. Http responses seem to be faster as well. The compilation from source is quite straight forward as well, with no dependencies.

You'll need to configure proxy settings on the box now, e.g.:
apt

Ubuntu (Feisty) Installation on Toshiba Tecra P5

Sunday, September 02, 2007

A place for my notes on the things I've done to get Xubuntu Feisty (Ubuntu is the same procedure) running from scratch on my Toshiba Tecra P5 laptop (PTS53A-02F01D).

Started by trying to boot into the LiveCD. This failed with:
/bin/sh: can't access tty; job control turned off
This message is a symptom of any boot problems - after some figuring out it turned out that there were problems with the cd module.
To fix, restart and on the boot screen, push F6. Edit the boot command ('e'), add:
break=top
(type 'b') to boot
This causes booting to stop early in the boot process (I think) and lets you type in stuff. When the prompt comes up, type:
modprobe piix
exit
This loads the module required to read the cd.

Booting then seems to continue happily but eventually it just freezes with text on the screen. This is because it doesn't recognise the video driver properly. We need to use the xorg default driver for now.
Pushing Ctrl+Alt+F1 takes you to the single user login.
sudo -s
vi /etc/X11/xorg.conf - (This uses the editor 'vi'. If you're not familiar with this, use 'i' to change to edit mode, 'esc' to come back out of edit mode, 'x' to delete a letter (when not in edit mode), ':w' to save (write) the file and ':q' to quit.)
change driver "nv" to "vesa" then exit
/etc/init.d/gdm restart
And Ubuntu should boot!

So play with it, enjoy the LiveCD, and when ready, double click 'install' on the desktop.

At first it couldn't manage to partition the hard drive, and unfortunately killed Windows :(.
-----------------------------------------------------------------------------------------------------------
ONLY DO THIS SECTION IF IT CAN NOT WRITE THE PARTITIONS - THIS WILL KILL WINDOWS.

I managed to get the disk manageable again by running:
mkfs /dev/sda
Now I could partition with:
cfdisk
--------------------------------------------------------------------------------------------------------------------------------

Congratulations, you should now be booting into Ubuntu :)

CD
So, in order to get continued cd support, we need to tell Ubuntu to load piix each time it boots. To do this, open a terminal and type:
sudo vi /etc/modules
To the end of this file, add:
piix

Graphics
I had difficulty setting up the nvidia graphics driver and really wanted the goods. So I found envy. Brilliant. Get it, run it. It downloads and installs the correct nvidia proprietary video drivers.

Sound
Initially I had a hardware problem so couldn't get sound at all which was very frustrating. Now that the hardware's fixed, it's fine. (Antony Williams also has a great script for automatically getting the latest alsa development drivers, should you need them.) Currently, plugging in headphones has no impact (i.e. sound still comes out of speakers and headphones are dead), so will update here when I resolve.
EDIT (Feb 08): I now have headphones sound as of alsa v1.0.16. You can find out your current alsa version by running:

alsamixer -v

Use the script above to get this version if you don't have it. Issues still outstanding with sound:
  1. I need to mute the main speakers manually when I plug in the headphones
  2. Microphone doesn't work, either built-in or plugged-in


--------------------------------------------------------------------------------------------------------------------------------
Upgrade
-Gutsy
Upgraded to gutsy gibbon October 07 without a hitch. Great advances, so highly recommend. Still sticking with the lighter-weight Xubuntu distro, using the xfce window manager. It's nice :)

Wireless
Prior to Gutsy, ndiswrapper was needed to run the Tecra's Intel Corporation PRO/Wireless 4965 AG network card. From gutsy onwards, however, it is supported with the iwl4965 driver (pre-installed). Hurrah!
I still have to use WEP with my router (I know!), so just remember with WEP to use Hex keys, not ASCII and it should work fine.
If you aren't using network manager like I'm not (trying to minimise services), then EDIT:if you boot with wireless switched off, you'll need to do 'sudo ifdown wlan0' then 'sudo ifup wlan0' after switching it on use wicd.

--------------------------------------------------------------------------------------------------------------------------------
Upgrade
-Hardy
Upgrade went without a hitch. Have upgraded successfully from Feisty to Gutsy to Hardy (and have now been using that for 6 months).

mac boot tricks

Monday, June 04, 2007

Hold down the following keys at boot time for:

Single user: command + s

Select boot drive: opt

Boot from dvd drive: c


At command line, mount the harddrive by: # /sbin/mount -wu /
Start OS X by: # /sbin/SystemStarter

exact copies in unix

Thursday, May 03, 2007

So often you want to copy files and folders between directories, but using cp all the file permissions are stuffed up and symlinks just cause problems. Not with good old tar!

cd into source dir

$ tar cf - * | (cd ../targetdir; tar -xf -)

with 'sudo' before each tar if required.

It's too good!

examining pkg package contents

On mac osx

$ lsbom {package name}.pkg/Contents/Archive.bom


Very handy for uninstalls!