The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Assign o/p of awk to a variable c2b2 Shell Programming and Scripting 8 04-01-2009 08:50 AM
retrieve a value and assign it to a variable Satyak Shell Programming and Scripting 1 06-17-2008 05:41 AM
assign a value to a variable Shivdatta Shell Programming and Scripting 10 01-17-2007 07:40 AM
assign value to variable using AWK HAA Shell Programming and Scripting 4 12-06-2006 11:43 AM
Assign the returned value of a function to a variable trivektor Shell Programming and Scripting 2 09-29-2006 05:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-17-2008
Satyak Satyak is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 85
Post 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 (permalink)  
Old 06-17-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
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 (permalink)  
Old 06-17-2008
Satyak Satyak is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 85
Post 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 (permalink)  
Old 06-17-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,309
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 (permalink)  
Old 06-17-2008
Satyak Satyak is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 85
Post 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
  #6 (permalink)  
Old 06-17-2008
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,927
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:38 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0