Monday, August 27, 2007

Removing all blank space in filenames

Here is a simple script to remove blank space in filenames in a directory tree. One could definitely use that script to change other characters too.
You can use it as a script or a single command line.

IFS=$'\n';for files in `find . -type f`; do NewFile=`echo $files | sed 's/ /_/g'`; mv "$files" $NewFile; done;unset IFS

Tuesday, August 21, 2007

Recovering from a hard disk crash on Sun servers

A server was setup with a mirror of 2 internal disk. This mirror was created using Solaris 9 built-in disk tools : disksuite.
Following a reboot, one of the 2 disks died and it was the primary boot disk ( of course ! ). So the server was not able to boot. We had to find a way of booting from the second disk.
At the ok prompt we created a new alias :
nvalias disk2 /pci@1f,4000/scsi@3/disk@0,0
then
boot disk2
and the server booted. The challenge here was to find the correct syntax for the device. So we typed in :
show-devs
We saw 2 disks. From another identical server, we typed in /usr/sbin/prtconf -vp :
Node 0xf002ce38
screen: /pci@1f,2000/TSI,gfxp@1
net: /pci@1f,4000/network@1,1
disk: /pci@1f,4000/scsi@3/disk@0,0
cdrom: /pci@1f,4000/scsi@3/disk@6,0:f
tape: /pci@1f,4000/scsi@3,1/tape@4,0
tape1: /pci@1f,4000/scsi@3,1/tape@5,0
tape0: /pci@1f,4000/scsi@3,1/tape@4,0
disk6: /pci@1f,4000/scsi@3/disk@6,0
disk5: /pci@1f,4000/scsi@3/disk@5,0
disk4: /pci@1f,4000/scsi@3/disk@4,0
disk3: /pci@1f,4000/scsi@3/disk@3,0
disk2: /pci@1f,4000/scsi@3/disk@2,0
disk1: /pci@1f,4000/scsi@3/disk@1,0
disk0: /pci@1f,4000/scsi@3/disk@0,0
scsi: /pci@1f,4000/scsi@3
floppy: /pci@1f,4000/ebus@1/fdthree
ttyb: /pci@1f,4000/ebus@1/se:b
ttya: /pci@1f,4000/ebus@1/se:a
keyboard!: /pci@1f,4000/ebus@1/su@14,3083f8:forcemode
keyboard: /pci@1f,4000/ebus@1/su@14,3083f8
mouse: /pci@1f,4000/ebus@1/su@14,3062f8
name: 'aliases'

This is where we found the string for the nvalias command.

A nice link for all openboot command is : http://www.adminschoice.com/docs/open_boot.htm

Thursday, August 9, 2007

websm on Fedora core 6

I recently installed FC6 on my linux workstation. Everything was fine until I tried running IBM websm management console.
I got the following error message :
java full version "J2RE 1.4.2 IBM build cxia32142-20050609"
+ java -Xbootclasspath/p:auiml/xerces.jar -Xms20m -Xmine4m -Xmx512m -DWEBSM_NO_REMOTE_CLASS_LOADING=false -DWEBSM_NO_SECURITY_MANAGER=false -Djava.security.policy=../config/websm.policy '-Dawt.appletWarning=Remote class Window' -DWEBSM_ALL_PERMISSIONS_FOR_SECURE=true -DWSMDIR=/opt/websm com.ibm.websm.console.WConsole
java.lang.ExceptionInInitializerError
at com.ibm.websm.etc.EImageCache._init(EImageCache.java:164)
at com.ibm.websm.etc.EImageCache.init(EImageCache.java:255)
at com.ibm.websm.etc.EImageCache.(EImageCache.java:152)
at com.ibm.websm.bridge.WSessionMgr.(WSessionMgr.java:185)
at com.ibm.websm.bridge.WSessionMgr.(WSessionMgr.java:217)
at com.ibm.websm.bridge.WSessionMgr.getSessionMgr(WSessionMgr.java:241)
at com.ibm.websm.gevent.GEventSupport.(GEventSupport.java:34)
at com.ibm.websm.gevent.GEventSupport.doSetup(GEventSupport.java:97)
at com.ibm.websm.gevent.GEventSupport.addEventListener(GEventSupport.java:115)
at com.ibm.websm.diagnostics.IDebug.Setup(IDebug.java:789)
at com.ibm.websm.diagnostics.IDebug.enabled(IDebug.java:1110)
at com.ibm.websm.diagnostics.Diag.(Diag.java:53)
at com.ibm.websm.console.WConsole.main(WConsole.java:1641)
Caused by: java.lang.NullPointerException
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2171)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:2006)
at java.lang.Runtime.loadLibrary0(Runtime.java:824)
at java.lang.System.loadLibrary(System.java:908)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:76)
at java.security.AccessController.doPrivileged1(Native Method)
at java.security.AccessController.doPrivileged(AccessController.java:287)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1488)
at java.awt.Toolkit.(Toolkit.java:1511)
... 13 more


I don't know exactly what was wrong but it had something to do with my java installation. So I edited the file /opt/websm/bin/wsm and did the change below :

BEFORE
#Set new path to WEBSM export PATH=../_jvm/bin:../bin:/bin:/usr/bin:/opt/kde3/bin echo PATH = $PATH

AFTER
#Set new path to WEBSM export PATH=/usr/java/jre/bin:../_jvm/bin:../bin:/bin:/usr/bin:/opt/kde3/bin echo PATH = $PATH

Then I run it : ./wsm and got the following message :
USING JAVA:
java full version "1.5.0_10-b03"
+ java -Xbootclasspath/p:auiml/xerces.jar -Xms20m -Xmine4m -Xmx512m -DWEBSM_NO_REMOTE_CLASS_LOADING=false -DWEBSM_NO_SECURITY_MANAGER=false -Djava.security.policy=../config/websm.policy '-Dawt.appletWarning=Remote class Window' -DWEBSM_ALL_PERMISSIONS_FOR_SECURE=true -DWSMDIR=/opt/websm com.ibm.websm.console.WConsole
Unrecognized option: -Xmine4m
Could not create the Java virtual machine.


So I edited again the file and took out the option parameter for the JVM :
BEFORE
java ${BOOTPATH} -Xms$W_HEAP_MIN_SIZE -Xmine$W_HEAP_INC_SIZE -Xmx$W_HEAP_MAX_SIZE $ACCESSIBLE -DWEBSM_NO_REMOTE_CLASS_LOADING=$WNRCL -DWEBSM_NO_SECURITY_MANAGER=$WNSM $WSMSSL -Djava.security.policy=../config/websm.policy -Dawt.appletWarning="Remote class Window" -DWEBSM_ALL_PERMISSIONS_FOR_SECURE=true -DWSMDIR="$WSMDIR" com.ibm.websm.console.WConsole

AFTER
java ${BOOTPATH} -Xms$W_HEAP_MIN_SIZE -Xmx$W_HEAP_MAX_SIZE $ACCESSIBLE -DWEBSM_NO_REMOTE_CLASS_LOADING=$WNRCL -DWEBSM_NO_SECURITY_MANAGER=$WNSM $WSMSSL -Djava.security.policy=../config/websm.policy -Dawt.appletWarning="Remote class Window" -DWEBSM_ALL_PERMISSIONS_FOR_SECURE=true -DWSMDIR="$WSMDIR" com.ibm.websm.console.WConsole

I can now run websm on my workstation.