Sponsored Content
Full Discussion: Parameter Passing problem
Top Forums Shell Programming and Scripting Parameter Passing problem Post 302336860 by Raamc on Thursday 23rd of July 2009 03:12:10 AM
Old 07-23-2009
Total script as below

#!/usr/bin/ksh
#####################################
# Starting the Main Script
#####################################
set -v on
set -x on
ScrName=`basename ${0}`
NOW=`date`
echo ${1}
echo ${2}
#
#-------------------------------------
# Routine for ERROR HANDLING
#-------------------------------------
#error_handle ()
#{
#echo "----------------------------------------->"
#echo "${NOW} ${ScrName} Error Handling...!"
#echo "----------------------------------------->"
#echo
#echo " ERROR Occured while ${1}"
#echo " EXIT from the program ......!"
#exit 1
#}
#--------------------------------------
# Check Command line arguments
#--------------------------------------
if [ $# -ne 2 ]
then
echo " ${NOW} ${ScrName} : Invalid Parameter list..."
echo " ${NOW} ${ScrName} : Script needs TWO parameters"
echo " ${NOW} ${ScrName} : Param1--Input file path"
echo " ${NOW} ${ScrName} : Param2--Output file path"
exit 1
fi

#--------------------------------------
# Get Log Directory
# and populate Log variables
#--------------------------------------
LogDate=`date "+%Y%m%d"`
LogDiry="${2}"
LogFile="${LogDiry}/SELUPD_${LogDate}.log"
#--------------------------------------
# Automatically Redirect STDOUT and STDERR to log file
#--------------------------------------
exec >${LogFile}
exec 2>${LogFile}

//////some logic
done
set -v off
set -x off
exit 0
#####END OF THE SCRIPT##########

i am calling the script as
sh script_name /home/user/work/infile /home/user/work/outfile

even i tried with the following calls
ksh script_name /home/user/work/infile /home/user/work/outfile
script_name /home/user/work/infile /home/user/work/outfile
./script_name /home/user/work/infile /home/user/work/outfile

but no use.

if i issue the command , echo $SHELL, it is giving the output as /usr/bin/bash.

I tried to login into ksh by issuing /usr/bin/ksh and called the script, but no use.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

parameter passing

Hallo everyone, This is my problem below: /home/cerebrus/pax=>vat class2.sh ksh: vat: not found /home/cerebrus/pax=>cat class2.sh #!/bin/ksh set -x bdf|grep appsdev|awk '{ print $5 }'> class3 dd={cat class3} echo $dd /home/cerebrus/pax=> /home/cerebrus/pax=>./class2.sh + bdf +... (8 Replies)
Discussion started by: kekanap
8 Replies

2. Programming

Passing parameter to makefile?

Hi, How to pass parameter to makefile? Please let me know if any one knows and also please put an example of makefile with this feature. thanks, Manju. (3 Replies)
Discussion started by: manju_p
3 Replies

3. Shell Programming and Scripting

wrong parameter passing!

Hi all I have a script which will take input as filename and passes it to a java program. It is as follows -------------------------------- FILENAME=$1 echo $FILENAME ${JAVA_HOME}/bin/java -cp DateProvider $FILENAME ------------------------------------------------- when I execute the same... (2 Replies)
Discussion started by: malle
2 Replies

4. Shell Programming and Scripting

Passing asterisk As A Parameter

I have written a Shell Script Program which accepts 3 parameters as shown below: ./calc 20 + 2 in the above line ./calc is the Shell Script itself with 3 parameters, namely: 20 + and 2. Well, now let's look inside the Script: result=$1$2$3 echo $result The output will be as... (8 Replies)
Discussion started by: indiansoil
8 Replies

5. Shell Programming and Scripting

Passing parameter in quotes

Hi, PW='/as sysdba'; export PW in other module I call sqlplus ${PW} (this line I unable to change!) How I can define PW so that sqlplus calls PW in quotes i.e sqlplus '/as sysdba' I tried like this PW="'/as sysdba'"; export PW - no luck Thanks in advance (2 Replies)
Discussion started by: zam
2 Replies

6. Shell Programming and Scripting

Positional parameter passing

Hi All, When passing parameters to a sheel script, the parameters are referenced by their positions such as $1 for first parameter, $2 for second parameter. these positional values can only have values ranging from $0-$9 (0,1,2,3...9). I have a shell script meant to accept 20 parameters. for... (3 Replies)
Discussion started by: ogologoma
3 Replies

7. Shell Programming and Scripting

Passing a parameter to AWK

Hi All, I am trying to pass a parameter to AWK on my KSH shell prompt as below. var1=2 echo $var1 awk -v var2=${var1} '{print var2}' testfile.txt I am passing the input file (testfile) to awk to get some o/p. It is having 10 records. When I run AWK, it is throwing the following errors... (1 Reply)
Discussion started by: Raamc
1 Replies

8. Programming

passing float parameter

I am surprised by GCC (this is ver. 4.2.4, Ubuntu 32 bit Intel) when a function declares a float parameter and it's prototype is missing, the parameters are messed up. Please see my code below: ~/test$ cat x1.c #include <stdio.h> #include <stdlib.h> set_p(int p1, float p2, int p3, int p4)... (7 Replies)
Discussion started by: migurus
7 Replies

9. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

10. Shell Programming and Scripting

Passing parameter more than 9

Hi, I've written a script where eleven parameter to be passed from command line which is inserting into an oracle table, it is working but the tenth and 11th parameter are not accepting as given it is referring to 1st parameter. HERE IS THE SCRIPT #!/bin/ksh #set -o echo $*... (4 Replies)
Discussion started by: sankar
4 Replies
escape(1)							Mail Avenger 0.8.3							 escape(1)

NAME
escape - escape shell special characters in a string SYNOPSIS
escape string DESCRIPTION
escape prepends a "" character to all shell special characters in string, making it safe to compose a shell command with the result. EXAMPLES
The following is a contrived example showing how one can unintentionally end up executing the contents of a string: $ var='; echo gotcha!' $ eval echo hi $var hi gotcha! $ Using escape, one can avoid executing the contents of $var: $ eval echo hi `escape "$var"` hi ; echo gotcha! $ A less contrived example is passing arguments to Mail Avenger bodytest commands containing possibly unsafe environment variables. For example, you might write a hypothetical reject_bcc script to reject mail not explicitly addressed to the recipient: #!/bin/sh formail -x to -x cc -x resent-to -x resent-cc | fgrep "$1" > /dev/null && exit 0 echo "<$1>.. address does not accept blind carbon copies" exit 100 To invoke this script, passing it the recipient address as an argument, you would need to put the following in your Mail Avenger rcpt script: bodytest reject_bcc `escape "$RECIPIENT"` SEE ALSO
avenger(1), The Mail Avenger home page: <http://www.mailavenger.org/>. BUGS
escape is designed for the Bourne shell, which is what Mail Avenger scripts use. escape might or might not work with other shells. AUTHOR
David Mazieres Mail Avenger 0.8.3 2012-04-05 escape(1)
All times are GMT -4. The time now is 10:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy