manage function's output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting manage function's output
# 1  
Old 10-27-2008
manage function's output

Hi all,
how i can get an calculated value from a function
for exemple
my function is like
Code:
function getMyPseudo {
..
..
echo "Rambler"
}

i need to put the printed string into a variable
sommeting like :

Code:
MYPSEUDO=getMyPseudo
print $MYPSEUDO

in that case, the out put i need is "Rambler"

thank you in advance
# 2  
Old 10-27-2008
save it in a file, then read it in
# 3  
Old 10-27-2008
thank you,

how i can do it

(i'm novice in KSH)

best regards
# 4  
Old 10-28-2008
Code:
a()
{
echo "aa"
}
s=`a`
echo " --> "$s

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Avoid single line output from function

I am new to shell scripting and wished to get few things clarified. While calling functions within shell script, output comes out as single line irrespective of the no of echos or newlines I tried within function + the echo -e used to invoke function ( as instructed online) : #!/bin/sh inc() {... (1 Reply)
Discussion started by: RMath
1 Replies

2. Shell Programming and Scripting

Sqlplus function output to bash

Hi, I would like to have the output from an Oracle procedure be captured into a bash variable, then emailed to me when it runs on the cron daily as such: ~~~~~bash script~~~~~~~~~~~ #!/bin/bash shellvar=`sqlplus -s <<EOF execute test(); commit; exit; EOF` echo $shellvar mail -s "email... (1 Reply)
Discussion started by: inlinesidekick
1 Replies

3. Shell Programming and Scripting

Function output to log file

Hi I have a shell script that does a whole bunch of things. For the sake of simplicity, assume it runs commands one two and three. What i ultimately need is the ability to display the output of the entire script on the screen as well as capture the output in a file. When I try to do it in the... (3 Replies)
Discussion started by: rch
3 Replies

4. Shell Programming and Scripting

Storing or Using Numeric Output From a Function

Hi all, I'm trying to implement a linear congruential pseudorandom number generator (<http://en.wikipedia.org/wiki/Linear_congruential_generator>), since $RANDOM and /dev/random aren't standardized. I'm referring to the Shell & Utilities volume of POSIX.1-2008, but I'm running into some odd... (3 Replies)
Discussion started by: PehJota
3 Replies

5. Shell Programming and Scripting

Split function input and output order

Dear Forum I'm Trying to use split function to split a string, but the output is not as the same order as of the string, please see simple example echo " " | nawk -v var="First;Second;Third;Fourth" ' BEGIN {split(var, arr,";") for(i in arr){print arr }}' The output is Second Third... (6 Replies)
Discussion started by: yahyaaa
6 Replies

6. Shell Programming and Scripting

Insert a function on an script's output

Hi, I have this code: #Convert epoch2date getdate() { perl -e ' use POSIX qw(strftime); $mydate = strftime "%c", localtime($ARGV); print $mydate; ' $1 } lsuser -a time_last_login gecos $username |awk '{print $1,$2,$3,$4}'|sed -e 's/gecos=/ Nombre: /' -e 's/time... (2 Replies)
Discussion started by: iga3725
2 Replies

7. Shell Programming and Scripting

In bash getting weird output from function ?

My script- result="" times() { echo "inside the times function" result=8 echo "Inside function $result" return $result } result=$(times) echo "the value is "$? echo "the value of result $result" when I run I get this, why the value still remain 0. $ ./func the value is 0 the value... (5 Replies)
Discussion started by: boy18nj
5 Replies

8. Shell Programming and Scripting

Send output of .SH to a function

Hello All, I am new to Shell script world. Please help me out with following query.. OS: AIX Shell Script I am trying to execute: showStatus () { echo $1 //Actually I need to do something with the input here... } ./serverStatus.sh | grep STARTED | awk '{print $5}' | showStatus... (3 Replies)
Discussion started by: raj_uk
3 Replies

9. UNIX for Dummies Questions & Answers

Output function into file

I have this shell: function AAAA { echo $* > Log1 } # main AAA "TEST" > Log2 ..... I not see the same output in the 2 files ; only Log1 result with the strings $* Log2 is without strings .... Why? (1 Reply)
Discussion started by: ZINGARO
1 Replies

10. Shell Programming and Scripting

Function output

I am working on a script that will recycle processes in an application identified by entry ids. I am reading a file, and using the first field in the records in file to store the entry ids. The second field is a description. I have two records in this file to test my script. My code to do this... (2 Replies)
Discussion started by: Skyybugg
2 Replies
Login or Register to Ask a Question