A bash script to monitor and log a CLI application

I am doing Java this session and have done my assignment 4 for socket practices.

The assignment contains 2 parts: Client and server.

I can’t modify the assignment to have proper log details (e.g. add time to logs) because it will lose marks 🙁

So, I did a bash script named “run”.

#!/bin/bash
# Author name: Need-Being
# Modification date: 14/10/2011
trap "" SIGHUP
cd Server
java JavaQuizServer 2>&1 | while read LINE
do
        echo "`date '+[20%y/%m/%d-%T]'`[java] $LINE" >> ../JavaQuiz.log
done

“java JavaQuizServer” is the line to execute the program. I add the time before whatever it output and send it to “JavaQuiz.log”
‘trap “” SIGHUP’ is used for ignore signal SIGUP that it can be alive after closing it parent process i.e. ssh.
Continue reading A bash script to monitor and log a CLI application

Some functionalities in STL is missing using CC

If you trying to compile source code, having some STL used, with CC in SunOS. You may fail.

For example:
If you use std::list::sort() in, you will get following error like this one:

Error: Could not find a match for std::list::sort(bool(int,int))

This happens because CC is using the old libCstd .

Continue reading Some functionalities in STL is missing using CC

unsigned long DOES NOT work on SOLARIS

When I doing an assignment of mine, I found the output of my Mac and school Solaris system is different which should be the same.

After a series of testing, I found that unsigned long does not work on solaris. It works same as unsigned int.

Look at the C code here:

/* Author Name: Need-Being
   Modification Date: 17/08/11
   File Description: Test unsigned int and unsigned long */

int main()
{
        unsigned int a = 0;
        unsigned long b;

        a = ~a; /* Make it maximun of unsigned int */
        b = a;
        b += 1;

        printf("%u\t%lu\t%s\n", a , b, (a < b)?"Works":"Does not work");
        printf("%d\t%d\n", sizeof(unsigned int), sizeof(unsigned long));

        return 0;
}

The output should be “4294967295 4294967296 Works” and “4 8”.

However, the actual output is

$ a.out
4294967295 0 Does not work
4 4

The unsigned long behaves the same as unsigned int.

Test is processed on a sparc machine in my faculty:

$ uname -a
SunOS banshee 5.10 Generic_144488-17 sun4u sparc SUNW,Sun-Fire-V240