ksh

How do I do an exact word match on a variable in ksh?

I used the following syntax as part of a ksh script to verify if the word Validation exists in LINE_FROM_FILE. [[ "${LINE_FROM_FILE##*Validation}" != "${LINE_FROM_FILE}" ]] && print "match Validation" The problem of this syntax is that it is also matching words like Valid or ValidationVALID etc. and my goal is to exactly match the wor...

How do i run a Java program from the command line using an Eclipse launch file???

Hi, i've been given the task of creating a ksh script which runs one Java program multiple times and another once. The idea is that the multiple runs test the ability of the single program to handle multiple threads. The issue i am having is that i want to use a .Launch file generated by Eclipse to specify the run time dependencies of ...

using backreferences regex in sed

I would like to remove multiple spaces in a file with a single character. Example cat kill rat dog kill cat I used the following regex, which seemed to matched in http://www.regexpal.com/ but wasn't working in sed. ([^ ])*([ ])* I used the sed command like so: sed s/\(\[\^\ \]\)*\(\[\ \]\)*/\$1\|/g < inputfile I ...

awk/sed for test command

hi from my ksh I have [[ ` echo $READ_LINE | awk '{print $2}' ` != SOME_WORD ]] && print "not match" can I get suggestion how to verify the same without echo command? ( maybe awk/sed is fine for this? ) lidia ...

shell script + calculate NETWORK IP by shell script

hi all the following question relevant for ksh script how to calculate the NETWORK IP according to NETMASK & IP ADDRES if there are some ready shell script to calculate the NETWORK IP for example NETMASK=255.255.255.0 IP=172.18.20.10 then NETWORK IP should be 172.18.20.0 lidia ...

if [ $? -ne 0 ] then syntax error then unexpected

Hi all, I have been trying to execute the following unix shell script which is not working. I am running it by ksh. echo $?; if [ $? -ne 0 ] then failed $LINENO-2 $5 $6 fi failed() { echo "$0 failed at line number $1"; echo "moving $2 to failed folder" } This is giving an error saying "Synatx error:then unexpected". Basicall...

shell script + constant spaces between the IP to the aliases name

hi all from my ksh script . echo $IP1 $ALIAS1 >> /etc/hosts echo $IP2 $ALAIS2 >> /etc/hosts echo $IP3 $ALIAS3 >> /etc/hosts I get the hosts file as the following 10.10.10.10 node1_star 10.10.10.100 node_from_some_where 10.10.1.1 Node_HP_MACHINE what the simple way to create the following hosts file view in or...

shell script + numbers sum

hi friends what the best simple elegant way to sum number in ksh or bash my example is about let command , but I want to find better way to summary all numbers for example num1=1232 num2=24 num3=444 . . . let SUM=$num1+num2+num3......... ...

How do i run a single class from the test folder of Maven from the command line?

Hi, i'm trying to run a number of classes which reside in the Maven 'test' folder from the command line which i will later combine to run in a ksh script. The issue i am having is that i can run files which are in the 'main' folder but i want to run another which is in the 'test' folder. Does anyone know, or have any ideas as to how t...

ksh - passing parameter with space

Hi there, am trying to pass a parameter with a space in ksh via variables. Here is some sample code to demonstrate the issue. As you will see the parameter with the space is later handled as two variables - not what I am after. Update - I didn't copy and paste all the code in the origianl question. * Contents of param_test.sh #!/bin...

check if file exists

#!/bin/ksh file_name=/home/file2.sh used_var=`grep "poet" $file_name` I want to check if file2.sh exists and also if used_var has some value or it has nothing. ...

Shell Script (bash/ksh): 20 seconds to read a variable

Hi guys, I need to wait for an input for 20 seconds, after that myscript should continue the execution. I've tried using read -t20 var however this works only on bash. I'm using ksh on Solaris 10. Can someone help me please? EDIT: 20 seconds is only an example. Let's pretend it needs to wait for 1 hour. But the guy could or could not ...

How to simulate key press event?

How to simulate key press event with ksh|bash script? ...

Setting another variable with a regular expression in KSH

I have a Korn shell script that I would like to change a variable based on another and a regex. What I want to happen is to generate a variable value like below, but without calling sed: $ echo 'orl,bdl,lap' | sed "s/,*orl//" | sed "s/^,*//" bdl,lap $ echo 'orl,bdl,lap' | sed "s/,*bdl//" | sed "s/^,*//" orl,lap $ echo 'or...

Prompt not displaying Hostname for AIX's KSH

Similar to question 1171663, AIX appears to not have the $HOSTNAME option available. $hname and $hostname are also non-existent. Other than doing the following within .profile - export HOSTNAME=`hostname` Is there an official manner where AIX users should be capable of getting the proper results when using: PS1="${HOSTNAME}:\${PWD...

Difficulty executing shell script with directory reference

Hey Guys, I have a simple script ... dir=`pwd` echo $dir cd ./selenium-grid-1.0.8/ CMD="ant -Dport=$1 -Dhost=$2 -DhubURL=http://172.16.1.137:4444 -Denvironment="$3"-DseleniumArgs="-firefoxProfileTemplate C:/software/rc_user_ffprofile -multiWindow" launch-remote-control" echo $CMD $CMD 2>&1 #End Whenever i run this command, i get: ...

test command in Korn shell (ksh)

I have a question on the test command in the Korn shell (ksh). I know -ne is for comparing integers and != is for comparing strings. How will the test command behave if one argument is a string and the other is an integer. I have below conditions in my code and both are working properly. myCount=1 myCount=`expr $myCount+ 0` temp=`ps -a...