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
------------------------------------------
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
------------------------------------------