Wednesday, June 1, 2011

": No such file or directory" Error on Linux

If you have ever encounter these errors on a Linux server: ": No such file or directory" or ": command not found" when attempting to run a script it may actually be a problem with the format of the file i.e. it may be a dos file. You can convert the file from dos to Unix using the following command:



$ dos2unix filename

N.B. On Solaris you may get a different error i.e. "^M: does not exist". You can use the same functionality to convert the file to Unix format.

Tuesday, April 19, 2011

Failed shutdown of Apache Portable Runtime on Tomcat 5.5.26

This "error" isn't really an error but a warning that the Apache Portable Runtime (APR) has failed to shutdown. This message can be ignored if APR isn't installed on your server.

Click here is more info on APR.

These forum links give more information:
http://www.coderanch.com/t/85960/Tomcat/Tomcat-Native-library-not-found
http://www.mail-archive.com/users@tomcat.apache.org/msg04625.html

And this link has information here is how to stop the error/warning from appearing:

http://issues.liferay.com/browse/LPS-3166?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel

Using curl to simulate a handset request

Previously I indicated on how one could use wget to simulate a handset request. You can also use curl to achieve something similar:

curl -v -A"Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 Nokia6110Navigator/" -H"x-up-calling-line-id: xxxxxxxxxxx" http://www.google.com

The 'xxxxxxxxxxx' should be replaced with the user's mobile number.

Thursday, February 17, 2011

java.lang.ClassFormatError: Truncated class file

Recently I kept getting this error when I copied over my .class files onto a remote server and attempted to run my java class on the server. I was using WinSCP to copy the files onto the server and the copy kept getting corrupted when I sent it across to the server. I shutdown WinSCP and started the process again which solved the problem.

Sunday, February 6, 2011

Programming NPV on Sharp EL-5250

Here is an example of how you can program your Sharp EL-5250 programmable calculator to calculate the NPV value when given yearly cash inflows.

Print"INITIAL CASH FLOW
Input C
Print "NO. OF YRS
Input N
Print"INTEREST
Rem IF I=12% NEED TO INPUT AS 0.12
Input I
Rem TIME COUNTER
T=1
Rem KEEPS THE CURRENT VALUE
X=0
Label CHECK
If T<=N Goto NPV
If T>N Goto THEEND
Label NPV
Print"NEXT CASH FLOW
Input F
X=X+(F/(1+I)^T)
T=T+1
Goto CHECK
Label THEEND
Rem NEED TO SUBTRACT INITIAL CASH FLOW
X=X-C
Rem X IS NOW THE NPV
Print X
End

Friday, February 4, 2011

Using ANT to create javadocs

Here is a very simple example to create javadocs using ANT. The fields should be replaced with your own parameters e.g. packagename should be replaced by the name of the package that contains the classes that you want to create javadocs for.

<target name="document">
  <javadoc destdir="doc" author="true" version="true" use="true" windowtitle="My JavaDocs">
    <fileset dir="src" defaultexcludes="yes">
      <include name="packagename/**">
      </include>

      <classpath>
        <fileset dir="lib">
          <include name="**/*.jar">           </include>
        </fileset>
        <doctitle><!--[CDATA[<h1>Mobile Text Adverts</h1>]]--></doctitle>
        <bottom><!--[CDATA[<i>Copyright &#169; 2011 Company Name. All Rights Reserved.</i>]]--></bottom>
      </classpath>

    </fileset>
  </javadoc>
</target>

Wednesday, January 26, 2011

Oracle escaping the % in like

Just figured out how to escape the % when using like in an Oracle SQL query e.g. if I want to get all rows from a table where the URL field contains "%20" which is the space in a URL.
select * from table_name where URL like '%!%20%' escape '!'

This indicates that '!' is the escape character and you would like to find all URLs that contain '%20'.