Function output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Function output
# 1  
Old 03-23-2007
Question 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 works! The problem is when I go to put it in a function, it again works, I just do not get the output to my shell session. Why is that?
How do I force the output to also echo to the shell session? It related to how I call the function? - Thanks ~SkyyBugg
=============================
If I comment out:
#doIt ()
#{
#}
#doit
I get the output!

I'd like to keep the function.

code:
cat /home/thomasm/cycler_printer_mt.ksh
#/usr/bin/ksh!
################################################
# Author: SKyyBugg
# Date 03-22-2007
# Purpose: to cycle servers
#
################################################
#
TODAY=`date +%m%d%y`
RTIME=`date +%c`
NODE_NAME=`hostname`
DOMAIN=build
UN=cycler
PW=allonsy
CYCLER=/cerner/w_standard/build_m04/aixrs6000/cycler
FILE_PATH=/unixadmin/bin
LOG=/unixadmin/log/${DOMAIN}.cycler.${TODAY}.log
IFS=":"
#
#
set -x
############
doIt ()
{

echo "Cycling servers for printers"
echo "In Domain: " ${DOMAIN}
echo ${CYCLER}
while read no descr
do
echo "Cycling Server: " ${no} ${descr}
${CYCLER} $no ${NODE_NAME} "-l" ${UN} ${DOMAIN} ${PW}
done< ${FILE_PATH}/.${NODE_NAME}.${DOMAIN}.cyc.pri.ser.lst >>$LOG
}
########
#MAIN
#######
doIt


~~~~~~
content of input file:
cat .cerntst1.build.cyc.pri.ser.lst
54:CPM Async Script
56:CPM Script Batch
# 2  
Old 03-23-2007
Try replacing:
done< ${FILE_PATH}/.${NODE_NAME}.${DOMAIN}.cyc.pri.ser.lst >>$LOG

by:
done< ${FILE_PATH}/.${NODE_NAME}.${DOMAIN}.cyc.pri.ser.lst | tee -a $LOG
# 3  
Old 03-23-2007
That did it! Seen use of tee before but never used it myself. I see that -a appends.
Thanks
SkyyBugg
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to capture system() function output in variable

How to capture system() function output in awk variable and the print that awk variable..... (8 Replies)
Discussion started by: bharat1211
8 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. Shell Programming and Scripting

manage function's output

Hi all, how i can get an calculated value from a function for exemple my function is like function getMyPseudo { .. .. echo "Rambler" } i need to put the printed string into a variable sommeting like : MYPSEUDO=getMyPseudo print $MYPSEUDO in that case, the out put i... (3 Replies)
Discussion started by: rambler
3 Replies

10. 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
Login or Register to Ask a Question