Home » Infrastructure » Unix » Passing arguments within same shell script
Passing arguments within same shell script [message #404740] Sat, 23 May 2009 02:07 Go to next message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
Hi,

Is there any way to echieve this. In my shell script i have a procedure


Code:
display_yes()
{
 echo $user
}


Then i call the procedure as below


Code:
user='test'
display_yes


How can i convert my procedure to accept arguments, and then when i call my procedure i can pass the arguments,

any help is very much appreicated
Re: Passing arguments within same shell script [message #404742 is a reply to message #404740] Sat, 23 May 2009 02:23 Go to previous message
ajitpal.s
Messages: 204
Registered: November 2006
Senior Member
got it. this will get the job done

#!/usr/bin/ksh

set_flag_no()
{
  echo $1
  echo $2
  echo $3

}

arg1="first"
arg2="secon"
arg3="thrid"

set_flag_no $arg1 $arg2 $arg3

arg1="1"
arg2="2"
arg3="3"

set_flag_no $arg1 $arg2 $arg3
Previous Topic: unix oracle process memory is high
Next Topic: Open ports in solaris 10
Goto Forum:
  


Current Time: Tue Dec 03 06:26:56 CST 2024