Friday, October 29, 2010

CIFS VFS No username specified cifs_mount failed code = -22

I wanted to use a credentials file instead of plain text user and password in fstab. I did that before in Ubuntu but for some reason in one of my servers I was getting the below:
# mount /mnt/mymount
mount: wrong fs type, bad option, bad superblock on \\windowsbox\shared,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount. helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

From system logs:
# dmesg|tail
[8628151.305806]  CIFS VFS: No username specified
[8628151.306141]  CIFS VFS: cifs_mount failed w/return code = -22

Solution

This was related to smbs not being installed:
# apt-get install cifs-utils
# which mount.cifs

Monday, October 25, 2010

monit action failed There is no service by that name

It came to my attention a google search for "monit: action failed -- There is no service by that name" did not return any hits.

At list in RHEL 5.5 (Tikanga) if you add new lines to monitrc you have to stop monit. In my case monit runs in inittab and so all I did was kill monit process.

Wednesday, October 20, 2010

Google Reader Notifier for Android

You should be automatically redirected to this url

Android RNotifier: RSS Google Reader Notifier


Google RSS Reader Notifier (RNotifier) allows you to receive notifications about unread RSS feeds configured in Google reader (Please note you must provide the complete email address and not just the user Id) and password to get notified.
* It checks Google reader feeds every 5 minutes.
* Just click the alert and land in Google reader mobile.
* Once installed it will start automatically every time you restart your phone.
* To stop checking for news just leave email and password empty.

Installation

Go to Google market and download Google RSS Reader Notifier or if navigating this page from your android device click here for a list of my applications. Then select from there.

Support

Use this page for support, questions, enhancements and feature requests. Post any issues here or drop me an email. I will be glad to help making this application better.

* If the application does not work as expected please check you actually have unread feeds in your Google Reader web interface from a Desktop/Laptop computer. Then be sure you have configured your correct email and password.
* If you suspect RNotifier is responsible for any performance issues you can install "TaskPanel" and kill "RNotifier".
* If you find out any problems (bugs) please install "Log Collector" and send me the content by email.

Note for IPhone customers

If there is enough demand I will make it available to the IPhone community as well. So drop me an email if interested.

Friday, October 15, 2010

Manually recover Liferay admin password

I forgot liferay admin password for a brand new production configuration. That is not big deal if the server has accessible SMTP but in my case the hosting provider hadn't enabled it so I knew my only option was to touch the database directly.

Password string "test" after encryption becomes 'qUqP5cyxm6YcTAhz05Hph5gvu9M=' so the below statement will take care of reseting the password to test (Of course in production you must never have the original test@liferay.com user so change that by the real admin email in your system)
UPDATE User_ 
SET password_='qUqP5cyxm6YcTAhz05Hph5gvu9M=' 
WHERE emailAddress='test@liferay.com';

Thursday, October 14, 2010

Specify liferay.home or else

First time it happens to me perhaps because I had used Debian in production before but at least in a fresh Red Hat Enterprise 5 I was getting the below error



java.lang.ArrayIndexOutOfBoundsException: 0
 com.liferay.portal.util.PortalInstances._getDefaultCompanyId(PortalInstances.java:232) 


This was solved as suggested in Liferay Forums

Add the below line in portal-ext.properties (change the path according to your specifics) then restart Liferay:

liferay.home=/opt/liferay-portal-5.2.3 

Friday, October 08, 2010

Android HNotifier: A Hotmail Notifier

Hotmail Email Notifier (HNotifier) allows you to configure a hotmail/live email (Please note you must provide the complete email address and not just the user Id) and password to get notified about new and unread emails.
* It checks Hotmail every 5 minutes.
* Just click the alert and land in hotmail mobile to check, reply or send new emails.
* Once installed it will start automatically every time you restart your phone.
* To stop checking emails just leave email and password empty.
* It won’t bother you with the same unread emails alert if you do not perform any actions after clicking the alert and no new emails are received.
* For support go to http://thinkinginsoftware.blogspot.com/hnotifier

Installation

Go to Google market and download Hnotifier or if navigating this page from your android device click here to get any of my applications

Support

Use this page for support, questions, enhancements and feature requests. Post any issues here or drop me an email. I will be glad to help making this application better.

* If the application does not work as expected please check you actually have unread emails in your hotmail web interface from a Desktop/Laptop computer. Then be sure you have configured your correct email and password.
* If you suspect HNotifier is responsible for any performance issues you can install "TaskPanel" and kill "YNotifier".
* If you find out any problems (bugs) please install "Log Collector" and send me the content by email.

Important Notice

At the moment I am not supporting the new security changes Microsoft has added to Hotmail. You can change the settings though. Just go to https://account.live.com/ManageSSL and deactivate SSL from there.

Note for IPhone customers

If there is enough demand I will make it available to the IPhone community as well. So drop me an email if interested.


* It checks Hotmail every 5 minutes.
* Click the alert and land in hotmail email mobile.
* Automatically restarts every time you turn on your phone.
* To stop checking emails just leave email and password empty.

Thursday, October 07, 2010

Pdf extraction: Split by bookmarks and merge back

Here is the task: Extract from a PDF those pages bookmarked as "you name it" in a new file keeping the original bookmarks related to the extracted pages.

Solution

1. Download pdfsam
2. Extract the content and execute run-console command (x permission is needed in unix/linux/osx).
3. Run the below to split the original file. Look how you can split at any bookmark level. In this case we split the file using the first level of bookmarks. There are other options available (for more info run ./run-console.sh -h split)
./run-console.sh -f /Users/nestor/Downloads/pdf/20100722_dailystm.pdf -o /Users/nestor/Downloads/pdf/pdfsam_out -s BLEVEL -bl 1 -p [BOOKMARK_NAME] split
4. Now let us say that you want to join only two files (you can join a whole directory if you want: for more info run ./run-console.sh -h concat). We just provide the input file paths and the output file path:
./run-console.sh -f /Users/nestor/Downloads/pdf/pdfsam_out/F-111-11111.pdf -f /Users/nestor/Downloads/pdf/pdfsam_out/F-444-AA33D.pdf -o /Users/nestor/Downloads/pdf/pdfsam_out/merged.pdf concat
5. In my case I had to rebuild the project from the sources as the resulting jar file (pdfsam-console-2.3.0e.jar) failed to correctly merge the files back. Basically files were containing first level bookmarks, all pointing to page 1.

Below are the changes I did to the project so I could build it.
Nestor-Urquizas-MacBook-Pro:trunk nestor$ svn diff ./ant/build.properties
Index: ant/build.properties
===================================================================
--- ant/build.properties (revision 1128)
+++ ant/build.properties (working copy)
@@ -1,8 +1,8 @@
 #where classes are compiled, jars distributed, javadocs created and release created
-build.dir=f:/build2
+build.dir=dist
 
 #libraries
-libs.dir=F:/pdfsam/workspace-enhanced/libraries
+libs.dir=/Users/nestor/Downloads/pdfsam-2.2.0-out/lib


Nestor-Urquizas-MacBook-Pro:trunk nestor$ svn diff ./bin/run-console.sh
Index: bin/run-console.sh
===================================================================
--- bin/run-console.sh (revision 1128)
+++ bin/run-console.sh (working copy)
@@ -15,8 +15,8 @@
 }
 
 
-DIRNAME="../lib/"
-CONSOLEJAR="$DIRNAME/pdfsam-console-2.0.5e.jar"
+#DIRNAME="../lib/"
+CONSOLEJAR="/Users/nestor/pdf/pdfsam/pdfsam-enhanced/pdfsam-console/trunk/dist/pdfsam-console/dist/pdfsam-console-2.3.0e.jar"

Below is the output of the ant command that generates the output jar which you will need to replace in the lib folder of your downloaded binaries (step 1)
Nestor-Urquizas-MacBook-Pro:trunk nestor$ ant -f ant/build.xml 
Buildfile: ant/build.xml

init:

make-structure:

compile:

build-jars:
      [jar] Building jar: /Users/nestor/pdf/pdfsam/pdfsam-enhanced/pdfsam-console/trunk/dist/pdfsam-console/dist/pdfsam-console-2.3.0e.jar

BUILD SUCCESSFUL
Total time: 1 second

Friday, October 01, 2010

Schedule Excel Macros with Parameters

I had this task assigned today and I thought about documenting where I found the pieces of the puzzle.

Of course we are talking about Windows OS here and so it makes sense to use just the Task Scheduler to set when the script should be run.

There is an excellent post that helped me start building the script. The only thing I added to it is the possibility to accept parameters that are injected into an Excel Subroutine that accepts parameters. As Excel will not show such subroutine as a valid macro if you want to call it from inside Excel you will need to use a non parametrized Sub that calls with test parameters the first one.

Below is the code for both of the Subroutines in Excel:
Option Explicit

' This is the routine that can accept parameters
Sub RunMacroFromParameters(param1 As String, param2 As String,  param3 As String)
     Range("E7").Value = param1
     Range("E8").Value = param2
     Range("J8").Value = param3
     MyMacroNeedingE7E8J8CellsAsInputParameters
End Sub

'Use this to test 
Sub ParametersTest()    
    RunMacroFromParameters "Miami", "1/1/2010", "3"
End Sub

Below is the code resulting from modifications on the original post

'''''''''''''''''''''''''''''''''''''''''''''''
'
' @Author: Modified from http://krgreenlee.blogspot.com/2006/04/excel-running-excel-on-windows-task.html#c4023873001264863808
' @Created: 10/01/2010
'
'
' @Description: Runs an Excel Macro and saves the result in a file adding the time stamp
'
' @Parameters (The first parameter if exists is added to the file name):
' 1. complete Path to the excel book
' 2. Name of the Macro
' 3. Extra parameters to be accepted by the Macro procedure. 
'  
'  
'
'
'
''''''''''''''''''''''''''''''''''''''''''''''''

'Create a WshShell to get the current directory

Dim WshShell
Set WshShell = CreateObject("WScript.Shell")

If (Wscript.Arguments.Count < 2) Then
Wscript.Echo "Runexcel.vbs - Required Parameter missing"
Wscript.Quit
End If


'retrieve the arguments

Dim strWorkerWB
strWorkerWB = Wscript.Arguments(0)


Dim strMacroName
strMacroName = Wscript.Arguments(1)

Dim firstExtraParameter
firstExtraParameter = Wscript.Arguments(2)

Dim strMacroParams
If (Wscript.Arguments.Count > 2) Then
    For i = 2 To Wscript.Arguments.Count - 1
        strMacroParams = strMacroParams & " ,""" & Wscript.Arguments(i)    & """"    
    Next    
End If


' Create an Excel instance
Dim myExcelWorker
Set myExcelWorker = CreateObject("Excel.Application")

' Disable Excel UI elements
myExcelWorker.DisplayAlerts = False
myExcelWorker.AskToUpdateLinks = False
myExcelWorker.AlertBeforeOverwriting = False
myExcelWorker.FeatureInstall = msoFeatureInstallNone


Dim StrPathNameNew

' Open the Workbook specified on the command-line
Dim oWorkBook

'it opens the file readonly
Set oWorkBook = myExcelWorker.Workbooks.Open (strWorkerWB,,True)

'on error resume next
' Run the calculation macro
strCommand = "myExcelWorker.Run " & """" & strMacroName & """" & strMacroParams
'Wscript.Echo "Runexcel.vbs - strCommand=" & strCommand 
Execute(strCommand )


if err.number <> 0 Then
' Error occurred - just close it down.
End If
err.clear
on error goto 0

Dim optionalToken
If IsNull(firstExtraParameter) or IsEmpty(firstExtraParameter) Then
    optionalToken = "_" & firstExtraParameter
End If

StrPathNameNew = replace(ucase(strWorkerWB),".XLS","") & optionalToken & "_" & year(Date()) & right("0" & month(date()),2) & right("0" & day(date()),2) & "_" & right("0" & hour(now()),2) & right("0" & minute(now()),2) & right("0" & second(now()),2) & ".XLS"
oWorkBook.SaveAs StrPathNameNew
oWorkBook.Close

' Clean up and shut down
Set oWorkBook = Nothing

' Don’t Quit() Excel if there are other Excel instances
' running, Quit() will shut those down also
if myExcelWorker.Workbooks.Count = 0 Then
myExcelWorker.Quit
End If

Set myExcelWorker = Nothing
Set WshShell = Nothing

Now you can run the command from the scheduler
C:\>"c:\RunExcel.vbs" "c:\myExcelWithMacro.xls" "RunMacroFromParameters" "Fort Lauderdale" "8/1/2010" "10"

Note that the script is generic enough to allow for automation of any Excel Macro whether it expects parameters or not. BTW the file is opened readonly as a new file is created everytime the script is run.

Followers