Function not running in script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Function not running in script.
# 1  
Old 07-11-2012
Function not running in script.

I an using the below functions in my script.
---------
Code:
checkRT()

{
subHeader "Runtime Check"
for nn in `cat $HOST_FILE|egrep -i 'msdp|ca|backup|db'|grep -v '#'|sed '/^$/d'|awk '{ print $1":"$2":"$3}'`
do
fhba=`expr $nn|cut -d: -f2`
fhba2=`expr $nn|cut -d: -f3`
subSubHeader $fhba2
ssh $fhba <<EOF

RTAlive=`/usr/ucb/ps -auxwww | grep "Dhttp.port=8080" | grep -v grep | awk '{print $2}' | wc -l`
    if [ "${RTAlive}" -eq "0" ]; then
      echo "*" $fhba ":" $fhba2 "Runtime is down.. Please check "  
    fi
exit
EOF
done
}

-----------------

it is giving below mentioned error:

Code:
Error:---
Pseudo-terminal will not be allocated because stdin is not a terminal.
Oracle Corporation      SunOS 5.10      Generic Patch   January 2005
You have new mail.
* 10.184.40.13 : sdpsrvr2-z5 Runtime is down.. Please check 
-sh: 0: not found

===
=== sdpTest
===
Pseudo-terminal will not be allocated because stdin is not a terminal.

--------------------

its not coming out of loop.. and === sdpTest is host name of another node of dummy IP.

Please help me in this
Thanks in Advance

Nandan


Moderator's Comments:
Mod Comment Please use code tags next time for your code and data.

Last edited by zaxxon; 07-11-2012 at 07:47 AM.. Reason: code tags
# 2  
Old 07-11-2012
You can try adding the switch -n or -t -t to your ssh line.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Will files, creaetd in one function of the same script will be recognized in another function?

Dear All. I have a script, which process files one by one. In the script I have two functions. one sftp files to different server the other from existing file create file with different name. My question is: Will sftp function recognize files names , which are created in another... (1 Reply)
Discussion started by: digioleg54
1 Replies

2. Shell Programming and Scripting

[bash] running a function remotely using ssh

Hi all. I need a bash script to run a function remotely. I think it should be similar to the following but can't figure out the exact syntax. Here is the script: #!/bin/bash function nu () { for var in {0..5}; do printf "$var, "; done; echo } ssh host "$(typeset -f); nu" ... (9 Replies)
Discussion started by: ziguy
9 Replies

3. Shell Programming and Scripting

Pass parameters to a function and running functions in parallel

Hi , I have a script which is using a text file as I/P. I want a code where it reads n lines from this file and pass the parameters to a function and now this script should run in such a way where a function can be called in parallel with different parameters. Please find below my script, it... (1 Reply)
Discussion started by: Ravindra Swan
1 Replies

4. Shell Programming and Scripting

While loop hangs in function running in background

Hello Everyone, I am writing a shell script to fetch log files from remote servers within a time range. It copies log files to local server, grep for date and then compares the time stamp of each log entry with the once specified. Below is the code. # Get log and Parsing function ... (1 Reply)
Discussion started by: kanagalamurali
1 Replies

5. Shell Programming and Scripting

Script function which checks if itself is already running

Hi All, I have a cron job set up which is set to run every 10 seconds. What I need to do is have the script do a check to see if it is already running such that if it is running it wont fire up additional instances and processes according to its normal process. For example if I have a script... (4 Replies)
Discussion started by: landossa
4 Replies

6. Shell Programming and Scripting

Running a function from a case statement

Hi, I have the below script that should take the command line option and run the desired script on another server. Only it doesn't seem to run the function, infact it just returns back to the command line. case $1 in 1) msgbacklog() ;; 2) jobstatus() ;; ... (10 Replies)
Discussion started by: chris01010
10 Replies

7. Shell Programming and Scripting

Running a function on a remote server via SSH in a script

I'm working on a script (mostly for practice) to simplify a task I have to do every now and then. I have a cluster with 6 servers on it, each server has a directory with a set of files called *.pid and *.mpid. Each file contains the pid of a process that may or may not be running on that server.... (3 Replies)
Discussion started by: DeCoTwc
3 Replies

8. Shell Programming and Scripting

ssh running on function

i have a problem regarding running an ssh command while inside "function" script structure #!/usr/bin/bash func1(){ script=$1 ssh user@server "$script" } cat script.txt | while read line do func1 $line done exit 0 the problem is when ssh ran,... (1 Reply)
Discussion started by: ryandegreat25
1 Replies

9. Shell Programming and Scripting

Running more than one function from a subroutine

Hi All I am new to perl so had one question. I have one Subroutine which works as expected and below is just an example. where I ran a command and check the output. so my question is if I have more than one command then how to check the results, meaning I want to add more command and check... (2 Replies)
Discussion started by: tannu
2 Replies

10. Shell Programming and Scripting

Running function or command concurrently in a bash script

I currently run a script over a vpnc tunnel to back-up my data to a remote server. However for a number of reasons the tunnel often collapses. If I manually restore the tunnel then the whole thing can continue, but I want to add into my script a section whereby while the transfer is taking place,... (8 Replies)
Discussion started by: dj_bridges
8 Replies
Login or Register to Ask a Question