Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

piped function does not pass variable value

Status
Not open for further replies.

fcic1

Technical User
Oct 21, 2003
4
US
Hi! I am a beginer in shell scripting and I have the following problem: I define a variable inside a function, but when i use the function with a pipe, i can't get the variable's value in main program.
How can i do to have the variable value after it exits the function? or any other idea how can i do this work ?
Thanks!

---------------------------------------------
#! /bin/ksh

user1="aaaaa"
pass1="bbbbb"

function1()
{
sleep 2
echo $user1
sleep 2
echo $pass1
sleep 1
var_1=`ls -l test1.out`
sleep 1
echo "echo $var_1"
sleep 1
}

function1 | telnet host

echo $var_1
------------------------------------------
 
I tried to export variables, but doesn't work.
.....
sleep 1
export var_1=`ls -l test1.out`
sleep 1
.....
 
See thread80-813738

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top