Accessing the Value of a parameter in KSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Accessing the Value of a parameter in KSH
# 1  
Old 08-25-2008
Question Accessing the Value of a parameter in KSH

Hi
I am new to this forum. Please forgive me, If I am wrong anywhere. I am trying to understand the below code. Can anyone help in understanding what is ${#ST} here. Is that the value of the first parameter??Smilie...what is exit 1 mean. Any clarification is greatly appreciated.

export ST=$1
export EN=$2
if [ ${#ST} -eq 0 ]
then
echo ${#ST}
echo ${ABORT} " START_STEP environment variable must be present"
echo "Process cannot be executed"
exit 1
fi
if [ ${#EN} -eq 0 ]
then
echo ${ABORT} " END_STEP environment variable must be present"
echo "Process cannot be executed"
exit 1
fi

Thank you,
Sudha
# 2  
Old 08-25-2008
${#ST} gives the length of the string value of the variable ST.
For example:
Code:
> ST='value'
> echo ${#ST}
5
>

Jean-Pierre.
# 3  
Old 08-25-2008
Question Accessing the Value of a parameter in KSH

Hi Jean-Pierre
Thank you for your prompt response. Even I want to know what is exit 1 there.
Thaks once again
sudha
# 4  
Old 08-25-2008
Tools exit statement

The 'exit' command is how programmers should end their programs. It is the cleaner way to program. That said, if a program runs normally and ok, the last line would be an
Code:
exit 0

If there were problems, and in your case you are checking for two kinds of problems, you should terminate the script execution with
Code:
exit 1

The reason for this is that you can tell if there was a previous problem in the prior executed program/script. Code like the following:

Code:
if [ "$?" -ne 0 ]
   then
   echo "previous program exited with an error !! "
fi

As time goes on, you could provide more info by associating error numbers to error text. One you probably see a lot on the internet is the "404" meaning page not found. Some websites know to anticipate a 404, and therefore provide better messages than just "error - page not found".
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Passing output parameter(Oracle) to variable in ksh Script

Hello, I have researched and tried many way to pass OUT parameter to be stored in variable in KSH Script.Still not success, please help. Here is my Store Procedure. create procedure testout3(v_in varchar2,v_out OUT integer) as begin v_out := 1; end; Here is my testvout.ksh #!/bin/ksh... (1 Reply)
Discussion started by: palita2601
1 Replies

2. UNIX for Dummies Questions & Answers

How to pass a parameter to an alias in ksh?

I want to do something like this: alias cd2="cd /data_saves/$(/opt/bin/util/getcustdb -i $@)" Where /opt/bin/util/getcustdb is an inhouse script to lookup customer db name based on a provided id number Then when I use the alias I can cd2 4567 and have it run "/opt/bin/util/getcustdb -i... (3 Replies)
Discussion started by: JourneyRider
3 Replies

3. AIX

aix:ksh: /usr/bin/rm: 0403-027 The parameter list is too long.

Hi, I am getting the below error message When i am trying to delete the files from the directory.Could you please guide me? rm *.aud ksh: /usr/bin/rm: 0403-027 The parameter list is too long. and find /oracle/admin/testP/adump/*.aud -mtime +5 -exec rm {} \; ksh: /usr/bin/find:... (3 Replies)
Discussion started by: nokiae63
3 Replies

4. Shell Programming and Scripting

Not getting the out value parameter of a DB call in the ksh file

Hi all Im calling a DB procedure as foll sqlplus -s $DB_USERID/$DB_PASSWD@$DB_NAME<<eof var var1 VARCHAR2(200); exec ODAS_BATCH_JOBS_RETRIEVE.retrieve_user_info(:var1); eof echo $var1 This echo is giving a blank. Also in case the package ODAS_BATCH_JOBS_RETRIEVE is in an un compiled... (2 Replies)
Discussion started by: Sam123
2 Replies

5. Shell Programming and Scripting

KSH list as function parameter

Hello, Could anyone help me with some KSH syntax? I'm trying to pass a list as a function parameter in a KSH? For example I have code like this: print_counter() { N=$1 C=$2 for A in $C; do echo "This is $N number $A" done } NAME=BRICK COUNT=" 1 2 3 4" ... (2 Replies)
Discussion started by: pn8830
2 Replies

6. Shell Programming and Scripting

Strange parameter passing problems (KSH)

Hi all, I'm having a rather peculiar problem involving parameter passing with declared functions in my shell script. Hope to get some advice here. A brief description of my code is as follows: However, I'm not getting the results I wanted. If I pass in $rdir, I'm going to end up... (4 Replies)
Discussion started by: rockysfr
4 Replies

7. Shell Programming and Scripting

accessing ksh variables from awk

hi everybody! i am running this ksh script for replacing a set of strings by another set of new ones. i am getting both these from a file. also, the strings that i want to replace, are sub-strings(can occur more than once in each chunk) in a big chunk of data that i have bulk-copied(bcp utility)... (1 Reply)
Discussion started by: trupti wagh
1 Replies

8. Shell Programming and Scripting

accessing a function in ksh from perl

is it possible? Because I know we could use open(A, `abc.ksh`); to access a ksh, but is it possible to access just one (or more) function from the ksh script? (2 Replies)
Discussion started by: ahtat99
2 Replies

9. Shell Programming and Scripting

ksh: dbfFILe: parameter not set

Having the following message returned: FIND REDLOG FILES..... ksh: dbfFILe: parameter not set When I attempt to perform the script below....#!/bin/ksh . $HOME/.profile # Initial Script Prerequisites ORACLE_SID=MDirect ; export ORACLE_SID REDOLOGDIR=$ARCLOGDEST ; export REDOLOGDIR... (2 Replies)
Discussion started by: Cameron
2 Replies

10. Shell Programming and Scripting

ksh parameter --- change

I am reading a file into a parameter in my program typeset nums_type if the contents of nums_type = asdfghbqwerty how do make a new paremeter eqaul to the 7th character of nums_type. like ${type} = b (2 Replies)
Discussion started by: frank
2 Replies
Login or Register to Ask a Question