Wednesday, December 28, 2011

Fedora 15 installation notes

These are some notes for my Fedora 15 setup.  Not very interesting, just a reminder of the steps I need to perform to get a fresh system up and running.

Steps

  1. read release notes
  2. read bug list
  3. install Software Development packages
  4. set network proxy (if installing at corp)
  5. enable network card - activate on boot
  6. edit /boot/grub/menu.lst
  7. add xterm to task bar, change default profile to unlimited, 9pt font
  8. add System Monitor to taskbar, change prefs to all monitors
  9. add my user to sudoers "su -", then edit /etc/sudoers
  10. download and install VMware Player "sudo sh VMwarePlayer.bundle"
  11. setup ntlmaps (if installing at corp), point firefox to use localhost:5865
  12. add free/non-free repos
  13. setup Google yum repo, download Chrome
  14. setup Google as default home page in Firefox
  15. install cinelerra dependencies
  16. download cinMonty
  17. compile cinMonty (autogen.sh/make --disable-mmx/make install)
  18. update VMware Tools
  19. remove nouveau (rpm -e xorg-x11-drv-nouveau --nodeps, nouveau.modeset=0 rdblacklist=nouveau in grub, yum install kmod-nvidia)
  20. install NVidia driver
  21. install rdesktop, setup sessions
  22. setup .bashrc with aliases
  23. install iptraf, mplayer, libcurl, iotop, ImageMagick, xfce4, xfce4 power, session and window managers
  24. run update
  25. System -> Sessions and Startup -> Auto save session on logout
  26. install system-config-lvm
That will provide for a decent base Fedora system.
TAG

Tuesday, December 27, 2011

scary awk magic

AWK is quite a powerful program that can do all sorts of gymnastics with structured text files.  Here's one example.

Say you have a file with four columns (depicted below) delimited by tabs:
-an id field
-a JSON string of dates
-another JSON string of values associated to those dates
-a last column that has the total of those values in column 3

Source File
6237    [20111102,20111103,20111104,20111105,20111106,20111107,20111108,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130,20111201,20111202,20111203,20111204,20111205,20111206,20111207,20111208,20111209,20111210,20111211,20111212,20111213,20111214,20111215,20111216]  [286,291,276,274,339,424,428,408,458,401,354,398,543,571,631,581,515,516,571,721,768,943,960,917,899,941,1168,1274,1256,1527,1472,1315,1323,1741,1826,1958,1988,1760,1662,1770,2088,2117,2325,2588,2214]    47786
6237    [20111102,20111103,20111104,20111105,20111106,20111107,20111108,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130,20111201,20111202,20111203,20111204,20111205,20111206,20111207,20111208,20111209,20111210,20111211,20111212,20111213,20111214,20111215,20111216]  [286,291,276,274,339,424,428,408,458,401,354,398,543,571,631,581,515,516,571,721,768,943,960,917,899,941,1168,1274,1256,1527,1472,1315,1323,1741,1826,1958,1988,1760,1662,1770,2088,2117,2325,2588,2214]    47786
6237    [20111102,20111103,20111104,20111105,20111106,20111107,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130]       [286,291,276,274,339,424,408,458,401,354,398,543,571,631,581,515,516,571,721,768,943,960,917,899,941,1168,1274,1256]        17684
6237    [20111102,20111103,20111104,20111105,20111106,20111107,20111108,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130,20111201,20111202,20111203,20111204,20111205,20111206]        [286,291,276,274,339,424,428,408,458,401,354,398,543,571,631,581,515,516,571,721,768,943,960,917,899,941,1168,1274,1256,1527,1472,1315,1323,1741,1826]      27316
10778   [20111102,20111103,20111104,20111105,20111106,20111107,20111108,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130,20111201,20111202,20111203,20111204,20111205,20111206]        [48,47,37,41,49,35,49,47,59,46,37,41,39,67,60,59,45,39,44,58,62,47,62,56,70,55,57,53,35,59,57,42,45,61,63]  1771
10778   [20111102,20111103,20111104,20111105,20111106,20111107,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130]       [48,47,37,41,49,35,47,59,46,37,41,39,67,60,59,45,39,44,58,62,47,62,56,70,55,57,53,35]   1395
10778   [20111102,20111103,20111104,20111105,20111106,20111107,20111108,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130,20111201,20111202,20111203,20111204,20111205,20111206,20111207,20111208,20111209,20111210,20111211,20111212,20111213,20111214,20111215,20111216]  [48,47,37,41,49,35,49,47,59,46,37,41,39,67,60,59,45,39,44,58,62,47,62,56,70,55,57,53,35,59,57,42,45,61,63,55,10633,51,41,36,37,62,41,53,45] 12825

The Goal
Notice that the row id's repeat a variable number of times.  My task was to use the first column as an index, and only take the last line in the file related to that index.


The Solution
The solution looks something hideous like this:
awk -F"\t" 'NR!=1 {a[$1]; b[$1]=$2 ; c[$1]=$3; d[$1]=$4} \
END{OFS="\t";for (i in a) printf("%s\t%s\t%s\t%s\n", i, b[i], c[i], d[i])}' \
file.txt

Breaking it apart into separate lines helps a bit (the backslash allows you to enter the pieces of the command on multiple lines in a Linux terminal window):
awk -F"\t"\
'NR!=1 {a[$1]; b[$1]=$2 ; c[$1]=$3; d[$1]=$4} \
END\
{OFS="\t";\
for (i in a)\ 
printf("%s\t%s\t%s\t%s\n", i, b[i], c[i], d[i])}'|\
file.txt

Let's take this apart piece by piece to see what it means.

awk -F"\t" start awk and use the tab delimiter to separate out the columns
NR!=1 read in all but the first record
a an array of values called a
a[$1] assign values to array named a, the values are to be found in the first column ($1) of the data file
b[$1]=$2 for the array b, at the index of $1, assign value of the second column ($2) of the data file
c[$1]=$3 for the array c, at the index of $1, assign value of the third column ($3) of the data file
d[$1]=$4 for the array d, at the index of $1, assign value of the fourth column ($4) of the data file
END do the following at the last
OFS="\t" output field separator is a tab
for (i in a) for each value in the array a, do the following
print.. print the current value for i (the index, the first column)
print the last value for the second column at index i: b[i]
print the last value for the third column at index i: c[i]
print the last value for the fourth column at index i: d[i]

Final Output
Now when I run the program, I get this for the output:
6237    [20111102,20111103,20111104,20111105,20111106,20111107,20111108,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130,20111201,20111202,20111203,20111204,20111205,20111206]        [286,291,276,274,339,424,428,408,458,401,354,398,543,571,631,581,515,516,571,721,768,943,960,917,899,941,1168,1274,1256,1527,1472,1315,1323,1741,1826]      27316
10778   [20111102,20111103,20111104,20111105,20111106,20111107,20111108,20111109,20111110,20111111,20111112,20111113,20111114,20111115,20111116,20111117,20111118,20111119,20111120,20111121,20111122,20111123,20111124,20111125,20111126,20111127,20111128,20111129,20111130,20111201,20111202,20111203,20111204,20111205,20111206,20111207,20111208,20111209,20111210,20111211,20111212,20111213,20111214,20111215,20111216]  [48,47,37,41,49,35,49,47,59,46,37,41,39,67,60,59,45,39,44,58,62,47,62,56,70,55,57,53,35,59,57,42,45,61,63,55,10633,51,41,36,37,62,41,53,45] 12825

Note there are only two lines now instead of seven and that I only have the last two instances of the value indexed in column one.

And that's some funky AWK magic.

Reference
http://en.wikipedia.org/wiki/AWK

Saturday, October 29, 2011

xfce4 irritations

In order to monitor the state of my RAID set, I needed to install the 3ware software pieces, especially the GUI.  The install documentation from 3ware is poor.  So I thought I'd create my own by taking some screenshots.  I was going to take screenshots using my window manager's screenshot program.  Unfortunately, ALT-PRINT did not work in XFCE.

I'm running XFCE instead of GNOME 3 because of GNOME 3's vertical workspace changing behavior.  You see, I edit video in Cinelerra and have the Program timeline, Resource and Viewer windows in one monitor and the Compositor in the right monitor.  Also, I use NVidia drivers in Twinview mode.  So for this video editing layout, I need the old GNOME2 horizontal workspaces.  GNOME3 breaks up the left and right monitor when you switch workspaces and you can only switch workspace vertically using CTRL-ALT-Up/Down.  Dumb.

Anyway, ALT-PRINT did not work in XFCE.  Reading here said it might have been a problem with multiple lines in .config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml

Reviewing that file, indeed I find multiple lines referencing the same keys (some under a "default" section, some lines under a "custom" section).  So I edited the file to remove the duplicate references and saved only those with my custom keyboard shortcuts.  My edits to get xfce-screenshooter to bind with both PrtScn and Alt-PrtScn ended looking like this:
      <property name="Print" type="string" value="xfce4-screenshooter -f"/>
      <property name="&lt;Alt&gt;Print" type="string" value="xfce4-screenshooter -w"/>

After removing the multiple entries for the Print key and restarting XFCE, I had my keyboard shortcuts back!  Yay!

Also, while reading that article, I noticed another user had a secondary problem that I had where the logout button for Xfce doesn't have the startup/shutdown option.  So here, it look like the problem might have been with xfce4-session.  I noticed I didn't have this program installed, so I installed it.  And now, I am happily running with a proper logout window:

Lastly, you can also customize what is displayed in the Log Out dialog using syntax like this:
xfconf-query -c xfce4-session -np '/shutdown/ShowSuspend' -t 'bool' -s 'false'

This edits the settings in this file:
.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml

So you see, this is why Linux is a pain in the ass.  You want to do something simple and basic stuff like screenshotting and shutdown/restart and power management is not installed by default or doesn't work.

argh!
sodo


Reference
http://forum.xfce.org/viewtopic.php?id=4781

Friday, July 01, 2011

301 permanent redirect using IIS

Here's a quick post describing how to place a 301 permanent redirect on a Microsoft IIS web server; specifically IIS6. On a Microsoft server, you can do a HTTP 301 Permanent Redirect two ways by using:
  • Javascript or Visual Basic code within your ASP page or
  • server administrative tools (the IIS management server console, iis.msc)
This is different from a Linux box, where you can use not only code or Apache to do the 301, but you can also take advantage of the .htaccess file for redirects.

Since the page I was trying to redirect was an HTML page, I wasn't able to put in any VB or Javascript code to perform the redirect. If I was using an ASP page, I could use some VB code like this:
< %@ Language=VBScript %>
< %
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”, http://www.example.com
%>

Instead, I used the IIS management console to edit the attributes of the file to permanently redirect the destination location of the file. In the example below, I have right-clicked on the Properties of a web resource available to IIS (a file under the wwwroot), have input my other blog "http://crazedmuleproductions.blogspot.com" as the destination URL and checked "a permanent redirection for this resource."

Lo and behold, this works..I am redirected to the proper location (shown below). However, when I use Firebug to inspect how the server is doing the redirects, I find that Firebug shows a "301 error" for the response code:

To confirm that it wasn't Firebug misinterpreting the response from the server, I used this site to confirm the response code:
http://www.internetofficer.com/seo-tool/redirect-check/
Using the internetofficer site's redirect checker, I found that the redirect checker showed the same response from the IIS server. So Firebug wasn't reporting incorrect information.

Finally, after a bit of googling, it seems that the "301 error" is just the way that the IIS server responds to the 301 permanent redirection setting. This is confusing, non-standard terminology, as it caused me to think that I had implemented the redirect incorrectly. Perhaps Microsoft will fix this in the future.

anyway..Happy 4th of July!
TAG

Wednesday, April 27, 2011

s3cmd through a proxy

For those who use Amazon's EC2/S3 cloud.
sodo@linux-8u67:~/Downloads/s3cmd-1.0.0> ./s3cmd --configure

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.

Access key and Secret key are your identifiers for Amazon S3
Access Key: enter accesskey
Secret Key: enter secretkey

Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/usr/bin/gpg]:

When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP and can't be used if you're behind a proxy
Use HTTPS protocol [No]:

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't conect to S3 directly
HTTP Proxy server name [http-proxy]:
HTTP Proxy server port [8888]:

New settings:
Access Key: enter accesskey
Secret Key: enter secretkey
Encryption password:
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: False
HTTP Proxy server name: http-proxy
HTTP Proxy server port: 8888

Test access with supplied credentials? [Y/n] y
Please wait...
Success. Your access key and secret key worked fine :-)

Now verifying that encryption works...
Not configured. Never mind.

Save settings? [y/N] y
Configuration saved to '/home/sodo/.s3cfg'

sodo@linux-8u67:~/Downloads/s3cmd-1.0.0> ./s3cmd ls
2011-04-05 19:03 s3://testbucket
2011-03-26 04:42 s3://trendtop

Yay! It works.
sodo

Also, I received this error message from YaST2 using SuSE Enterprise Linux 11 64-bit 11.1:
Problem: nothing provides python(abi) = 2.6 needed by s3cmd-1.0.0-4.1.i586

Resolution: install manually from http://s3tools.org/s3cmd

Reference
http://www.saltycrane.com/blog/2010/02/s3cmd-notes/

Sunday, April 17, 2011

resizing a linux partition using Parted Magic

I was running out of space on the root filesystem of my OpenSuSE 11.4 virtual machine. I needed a few extra gig, so I wanted to enlarge the root filesystem from 18GB to 22GB:
sfrase@linux-8u67:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 14G 4G 22% /
devtmpfs 372M 88K 372M 1% /dev
tmpfs 372M 1.1M 371M 1% /dev/shm
Thinking I could use Gparted, I stumbled upon something even easier..the Parted Magic OS. Parted Magic is a compilation of open source partitioning utilities in one smooth-looking OS in bootable iso format. The bootable iso is about 160MB and is available here:
http://partedmagic.com/doku.php?id=downloads

Overview
I had to do a few things to get the filesystem resized.
1) resized the virtual disk that VMware uses
2) booted the VM with the Parted Magic ISO in the virtual CD of the VM
3) ran GParted and expanded my filesystem
4) rebooted the system to see the expanded disk

Detail
I'll show you the steps in depth below:

In VMware Player settings, select the hard disk, click the Utilities link and press "Expand":


Specify a new maximum disk size:


After VMware resizes the virtual disk, I got a success message:


I mounted the ISO in the virtual CD drive:


Next, I booted the virtual machine. I pressed ESC (escape) while the vm is booting to display the boot menu:


I highlighted CDROM and press enter to start booting the Parted Magic iso:


Parted Magic has a really nice interface. Love the system monitors on the desktop!


Next, I double-clicked the icon labeled "partition editor". This is Gparted, the GNOME partition manager:


I double-clicked the filesystem I wanted to resize. In order to expand the size of the filesystem, I pulled the right tab in the graphic from its current position all the way to the right.


I clicked the resize button and saw the change I made:


I clicked Apply to confirm the changes:


It took a minute or two to resize the filesystem:


I checked out the steps the resize performs by clicking the little twisty:


Once resized, I rebooted the machine:


Now my disk has the extra 4GB of space that I needed! Hooray!
sfrase@linux-8u67:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 22G 14G 8G 22% /
devtmpfs 372M 88K 372M 1% /dev
tmpfs 372M 1.1M 371M 1% /dev/shm


Shrink
You can also shrink filesystems. For instance, I wanted to reduce the size of my root partition from 38GB to 7GB. Again, I used GParted and PartedMagic CD for the task.

Here's the Resize screen after I dragged the right arrow almost to the area on the filesystem that is used, as indicated by the yellow color:


Here's the screen while the job is in progress:


Once finished you'll see a message "All operations successfully completed." The job took about five minutes to complete.

So far, I've used GParted on ext3 and ext4 filesystems without issue.

Please, don't forget to donate a few dollars to the nice folks who compiled this very useful set of utilities.

TAG

Monday, April 11, 2011

weblogic 6.1 nastiness

I had to resurrect an old WebLogic 6.1 system today. Ooof! A conversion from IIS5 to IIS6. Went through quite a bit of h3ll.

1) Under Control Panel -> System -> Advanced -> Performance -> Data Execution Prevention had to be enabled for the specific WebLogic and java processes:
-beasvc
-java
-javac

Otherwise, I'd get errors in the Application Event Log and to the desktop.

See more here:
http://en.wikipedia.org/wiki/Data_Execution_Prevention#Windows

2) In IIS, the WebLogic ISAPI filter priority was set to *Unknown*. I resolved with help from Vivek's post here:
http://blogs.msdn.com/b/vivekkum/archive/2009/02/20/unknown-status-for-isapi-filter.aspx
-otherwise, IIS would hang

3) In IIS, the WebLogic DLLs need to be configured as Web Service Extensions and set to a status of Allowed

4) In IIS, unknown ISAPI extensions need to be Allowed
-otherwise, I'd get 404s from .wlforward

5) In IIS, the website needs to be run in IIS5 isolation mode
-otherwise, IIS would hang

6) The iisproxy.ini file needed to be copied to c:\weblogic
-otherwise, I'd get an HTTP 500 from .wlforward

7) Faulting application w3wp.exe, version 6.0.3790.3959, faulting module iisforward.dll
-caused by dll memory corruption trying to access Physical Address Extension memory
-resolved by adding /nopae to boot.ini
http://forums.iis.net/t/1158864.aspx
http://support.microsoft.com/kb/895575

Ugh!
TAG
Feel free to drop me a line or ask me a question.