retrieve a value from a function and assign it to a variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting retrieve a value from a function and assign it to a variable
# 1  
Old 06-17-2008
Java retrieve a value from a function and assign it to a variable

hi
i have a function.
parse()
{
qname="lpdma111"
qmgr="lpdma111"
qalias="lpqqali"
}

Now the requirement is i want ot get the vaues form the function

start()
{
//retireve the values from the parse function

}
# 2  
Old 06-17-2008
Put these statements in the parse function.
Code:
export qname
export qmgr
export qalias

Put these in the start function.
Code:
echo qname
echo qmgr
echo qalias

# 3  
Old 06-17-2008
Java retireve a value from a finction and assign it to a variable

hi nua7
i did the same as u mentioned.
but i want to use the values in the start function

please help
# 4  
Old 06-17-2008
The variables are all global, after calling the function the variables should be set.
Try this in your main function:

Code:
echo $qname
echo $qmgr 
.....

Regards
# 5  
Old 06-17-2008
Code:
#!/usr/bin/ksh93

parse()
{
    qname="lpdma111"
    qmgr="lpdma111"
    qalias="lpqqali"
}

start()
{
   print "QNAME: $qname"
   print "QMGR: $qmgr"
   print "QALIAS: $qalias"
}

parse
start

Output:
Code:
QNAME: lpdma111
QMGR: lpdma111
QALIAS: lpqqali

# 6  
Old 06-17-2008
Java retireve a value from a finction and assign it to a variable

getHostQueueDetails()
{
hostname=`hostname -s`
value=`grep $hostname queuedetails.properties`

parse $value
QueueManagerName=$QueueMgrName
echo $QueueManagerName
}
parse()
{
hostnm=$1
oldifs=IFS
IFS=,
set -- $hostnm
QueueMgrName=$1
ClusterName=$2
QueueNam1e=$3
QueueName2=$4
export $QueueMgrName
export $ClusterName

IFS=$oldifs
}
start()
{

echo "-------------------------ClusterName"
getHostQueueDetails

}
start


i am getting the output as "lpdma508=LPDMA520" but i want only
LPDMA520 .

please help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies

2. UNIX for Beginners Questions & Answers

Need to pass variable in a command and assign value to a variable

Hello All, Hope you're doing well ! I am trying below command to be passed in a shell script, header_date_14 is a variable and $1 is the name of a file I intend to pass as a command line argument, however command line argument is not being accepted. header_date_14=$(m_dump... (8 Replies)
Discussion started by: ektubbe
8 Replies

3. Shell Programming and Scripting

Shell assign variable to another variable

How can I assign a variable to an variable. IE $car=honda One way I can do it is export $car=honda or let $car=2323 Is there any other ways to preform this task (3 Replies)
Discussion started by: 3junior
3 Replies

4. Shell Programming and Scripting

Retrieve a particular value into a variable

Hi, i am writing a shell script that will execute a select query. the select query returns one specific value. Idql is used for quering in documentum... X = $ (idql <docbase> -U<username> -<pwd> -Rdqlqueryfile.dql << ! set heading off set footer off !) query in dqlqueryfile is... (0 Replies)
Discussion started by: kichu
0 Replies

5. UNIX for Dummies Questions & Answers

How to retrieve the value of variable in shell script which is called by crontab

There are two files one is shell script (sample.sh) and another is configuration file (sampl_conf.cfg) configuration file contains one variable $FTP_HOME. the value of this variable vaires for user to user. If user is say jadoo then value is /home/jadoo/ftp/, for user1 - /home/user1/ftp. The... (4 Replies)
Discussion started by: jadoo_c2
4 Replies

6. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

7. Shell Programming and Scripting

To retrieve gene name & function thorugh Genbank id (gi|9910297)

Hi , I have list of genbank id's and ref number in this format. gi|9910297|ref|NM_019974.1| I want to retrive the gene name and fuction for each genbank list. I have around 1300 gi numbers in my excel sheet. So anybody can help me to retrive the information from NCBI through perl script... (0 Replies)
Discussion started by: shibujohn82
0 Replies

8. Shell Programming and Scripting

Passing global variable to a function which is called by another function

Hi , I have three funcions f1, f2 and f3 . f1 calls f2 and f2 calls f3 . I have a global variable "period" which i want to pass to f3 . Can i pass the variable directly in the definition of f3 ? Pls help . sars (4 Replies)
Discussion started by: sars
4 Replies

9. Shell Programming and Scripting

retrieve a value and assign it to a variable

hi i have a properties file and i am retrieving a value from that file. now i want to assign the retieved value to a variable can u please help (1 Reply)
Discussion started by: Satyak
1 Replies

10. Shell Programming and Scripting

Assign the returned value of a function to a variable

Hi, Can anyone please show me how to assign the returned value of a function to a variable? Thanks. (2 Replies)
Discussion started by: trivektor
2 Replies
Login or Register to Ask a Question