Send output of .SH to a function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Send output of .SH to a function
# 1  
Old 11-25-2008
Bug 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

Result: nothing comes out on the console

Output of ./serverStatus.sh when run alone:
ADMU0503I: Retrieving server status for all servers
ADMU0505I: Servers found in configuration:
ADMU0506I: Server name: server1
ADMU0506I: Server name: nodeagent
ADMU0508I: Server name: "PVSDEV_AS1"
ADMU0508I: The Application Server "PVSDEV_AS1" is STARTED
ADMU0509I: The Application Server "server1" cannot be reached. It appears to be stopped.
ADMU0508I: The Node Agent "nodeagent" is STARTED

Expected Result:
PVSDEV_AS1
nodeagent
above 2 lines should be printed on the console (Again I need to do something with this in the function above.. but as of now trying to print it)

My Question:
Is my approach in the shell script right? or should I follow a different way?

Thank you in advance.

Cheers,
Raj
# 2  
Old 11-25-2008
Just wondering if my question is clear to all. To be short and sweet, I want the output of a sh file to function in my script.

Cheers,
Raj
# 3  
Old 11-25-2008
Here's one approach:

Code:
./serverStatus.sh | grep STARTED | awk '{print $5}'  | while read VALUE ; do
   showStatus $VALUE
done

# 4  
Old 11-25-2008
Thanks a lot jimbalaya.. it worked like charm...

Cheers,
Raj
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

2. Shell Programming and Scripting

Send email if Output is available

hello can anyone debug these lines cd /usr/local/scripts ./build update ./build versions | grep available if then mail -s "update for server `hostname`" $EMAIL else echo -e "$YELLOW No update $RESET" fi echo "Please press a key - Back to main menu . . ." ; read but... (3 Replies)
Discussion started by: nimafire
3 Replies

3. Shell Programming and Scripting

want to send 4 files output in one mail

Hi All , i have a wrapper HTML script -FS_CHECK_HTML_SCIPT_WT_Statusbar.sh which read a TXT file (script_KB.txt) and sends output to a mail in tabular format. TXT file is having 6 columns and so wrapper script create a table with 6 columns and supplies those 6 columns data from TXT file .... (2 Replies)
Discussion started by: deepakiniimt
2 Replies

4. Programming

unable to send a char parameter from main to a function

why does this not work? #include <stdio.h> #include <stdlib.h> char getFileMode(char charChanger) { char filetype; /*var to hold the value to be returned*/ filetype = charSetter; /*set filetype to "l" if it is a symlink*/ return filetype; } int main(void){ char... (8 Replies)
Discussion started by: bluetxxth
8 Replies

5. UNIX for Advanced & Expert Users

Output will send in mail

Hi All, Requirement is to select the data from database and send the output in mail. But the output should in HTML tabular format in mail body. For example my select command is : select ename,esal,edegn,dept from emp where deptno in (10,15); In the mail body the output should : Employee... (3 Replies)
Discussion started by: alex_us
3 Replies

6. Shell Programming and Scripting

How to send a string to function containing wild card?

Hey All, I am trying to send a string as an input parameter to a function which contains a wild card character - * However the function is taking it as: PS: The directory - '/path/to/my/dir/' has 3 files: file1.out, file2.out, file3.out However I want to disable this wild... (2 Replies)
Discussion started by: paragkalra
2 Replies

7. Shell Programming and Scripting

How to send a function all command line args?

I have this code, I thought it would automatically know the args sent to script when called from shell. But it seems to not see any... main script: . args . errors . opt . clean dbfile="" opfile="" # calls function in script below chkarg #check commands (2 Replies)
Discussion started by: gcampton
2 Replies

8. Solaris

Send cut output to basename

Hi, I'm running a command : pargs 20392 | egrep -e "-f "|cut -d " " -f3 | basename BUT the o/p of cut is not sending to basename. the o/p of: pargs 20392 | egrep -e "-f "|cut -d " " -f3 is /home/staff/Properties.cfg Appreciated ur help.. (2 Replies)
Discussion started by: axes
2 Replies

9. Solaris

how to send the output

Hi, how to send the output of a command directly to a file. For eg: am issuing metastat -a. How to send the output of this command to a file as well as mail. (3 Replies)
Discussion started by: rogerben
3 Replies

10. Shell Programming and Scripting

send function in socket

Hi All, I encountered a stange problem while doing a perl script to use socket. i need to transfer a file from client to sever. but error came as argument missing in send function.........Plz tell me the wt r the arguments in send and recv functions....... (0 Replies)
Discussion started by: trupti_rinku
0 Replies
Login or Register to Ask a Question