Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Thursday, February 2, 2012

Maven build on winows and unix


Windows paths differ from that of unix, linux, solaris, aix and sometimes it becomes challange to use one pom.xml for building on two different os.
Here is how one maven script can be used for building applications on windows and unix environments:



<profiles>
    <profile>
        <id>windows</id>
        <activation>
        <os>
            <family>windows</family>
        </os>
        </activation>
        <properties>
            <!-- windows based properties here -->
        </properties>
    </profile>
    <profile>
        <id>non-windows</id>
        <activation>
        <os>
            <family>!windows</family>
        </os>
        </activation>
        <properties>
            <!-- unix based properties here -->
        </properties>
    </profile>
</profiles>

Friday, October 21, 2011

Set/ List the file descriptor limits


Sets the file descriptor limit (hard and soft) to [number]
ulimit -n [number]

Sets the file descriptor hard limit to [number]
ulimit -H -n [number]

Sets the file descriptor soft limit to [number]
ulimit -S -n [number]

Shows the file descriptor limit (hard and soft)
ulimit -n

Shows the file descriptor hard limit
ulimit -H -n

Shows the file descriptor soft limit
ulimit -S -n

Useful UNIX commands



String operations (commonly used)
Equal: = (equal sign) 
Not equal: != (Not equal sign)
And: -a
Or: -o


Secure Copy
scp [local-file-path] user@host:/[remote-file-path]
scp myfiles*.jar user1@abc1234:/tmp/user1/

Secured Shell Commands
ssh user@host [unix-command] [unix-command-parameters]
ssh user1@abc1234 cp [local-file-path] [remote-file-path]
ssh userx@host123 "command-to-run-locally-1; command-to-run-locally-2"

Who all are logged into terminal
finger

To see list of all processes
top

List the file descriptors for a process id
lsof -p [process-id]

Get the length of the string
${#StringVariable}

Evaluate Mathematical/ General expression
Var1=`expr ${VAR-X} - $((${VAR-Y}*2)) - 5`
Var2=`expr substr ${TEXT1} ${Start-Index} ${End-Index}`

Secure FTP Command Sample
sftp user-x@server-y:/tmp/locationget ./abc/xyz.txt .


Read from XML Tag
function getTagValue
{
        _TAG=$( echo $( echo $1 | cut -d'<' -f2 ) | cut -d'>' -f1 )
        _OUTPUT=$( echo $( echo $1 | cut -d'>' -f2 ) | cut -d'<' -f1 )
}

function getValueFromTag
{
        # get the tag name from the text
        getTagValue $1
        case ${_TAG} in
        Target)
                _OUT1=$( echo ${_OUTPUT} | cut -d'#' -f1 )
                _OUT2=$( echo ${_OUTPUT} | cut -d'#' -f2 )
                echo "${_TAG} value1: ${_OUT1} and value2: ${_OUT2}"
        ;;
        User)
                echo "${_TAG} value: ${_OUTPUT}"
        ;;
        *)
                echo "ERROR: Incorrect TAG : ${_TAG} found!"
                exit 2
        ;;
        esac
}

getValueFromTag "new-env#right-now"
getValueFromTag "user-xxx"