Thursday 28 November 2013

gnuplot changing font

I was following some instructions on using gnuplot, however the instructions for changing the font used in the graphs was wrong. Therefore I had to figure out how to achieve this.
I was looking to output some graphs to png images, so I added the following to the top of my command file used to draw the graphs
set terminal png enhanced font "<full path to font>"
set output "<filename>"
There is also an environment variable GDFONTPATH which can be set to directories containing font files, if this is used the above lines can be changed to
set terminal png enhanced font "<font name>"
set output "<filename>"

Tuesday 26 November 2013

ioctl decoding

I was interested to know how to decode an ioctl hex string, I worked through the example described in the kernel documentation at /ioctl/ioctl-decoding.txt
Then I tested it out on an ioctl code listed in an error message in a server log, here is my working (this is for an x86_64 server, other architectures may vary)

ioctl code in hex is
cc770002

Which in binary is
11001100011101110000000000000010

First two bits gives us the macro used
11
this according to the document is _IOWR (Read/Write)

The next 14 bits give the size of the arguments
00110001110111
which in decimal is 3191

The next 8 bits are an ascii character, which in my example gives NULL (could well be an issue and why the message appears in the logs for that application)
00000000

The final 8 bits gives the function number, in my example this is
00000010
which in decimal is 2

If I had the sourcecode of the application I could go and look up this function using the character and the function number. In the example above, looks like a bug in the application is generating the wrong character and the ioctl call will fail.

Thursday 21 November 2013

bc setting defaults

I have never really thought much about this, but for years whenever I start bc I always set the number of decimal points (scale) by issuing

scale=<number>

To automatically set this (and other settings) place them into a file (I called mine .bcrc) and set the environment variable BC_ENV_ARGS to point to this file.

BC_ENV_ARGS=$HOME/.bcrc

To set this variable up for every shell add to your shells start up files.

Wednesday 20 November 2013

xchat username registration

I am sure I did this many years ago, but failed to remember exactly the steps I took.

I had the need to register my nick with a nick registration service on a particular IRC channel. I have tended to use xchat as it is available and simple to use.
To save me some time and so I don't have to remember to do it every time I thought I would automate this login.

In xchat's network list select the irc server you are connecting to and click edit, which will bring up a screen similar to the following
Edit Network dialog box





















In the "Connect command" box I added the command
load -e <filename>
where filename contained the commands I needed to login with the nick registration service (minus the leading "/" is would normally use with interactive commands). The commands were similar to
msg <registration service> login <nick> <password>

Wireless Bridging

I have just started a new job and have discovered that while I have an office, I cannot put everything on wireless, especially the new office IP phone I have been given. Therefore, I decided to combine to projects together, flashing of an old Linksys router with dd-wrt and setting up additional networking in my office so I can connect my office phone.
This seemed the simplest option rather than stringing cables all round the place, another good alternative could have been ethernet over powerline adapters, but no technical tweaking involved.

I followed the dd-wrt instructions for installation on my old linksys WRT54G router, making sure to follow all instructions to the letter. When it came to using tftp to install the new firmware on the system after 99 tries it failed, so I went back to an earlier step where in the Management Mode window a custom image created at the beginning of the process is uploaded. This must not have taken first time as the tftp worked first time.
Once dd-wrt was up and installed I had to connect it to my existing wireless AP, this was straight forward in the wireless settings I select client bridge and give it the details of my existing wireless network (ensure things match exactly). I also made sure that SIP firewall was off and no dhcp server was running on the router.
Once changes had been made and rooter rebooted (as necessary), I connected via ethernet cable a laptop and it successfully got a dhcp lease from the main access point and I was able to browse the web.