Pb in while loop with ssh command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pb in while loop with ssh command
# 1  
Old 10-10-2005
Pb in while loop with ssh command

Hi

I use the following command to check if my_base is active or not :
active_db=`${LOCAL_BIN}/ssh -l ${my_user} ${my_service} "ps -ef | grep ora_smon | grep ${my_base} | sed -e \"s/ */ /g\" | cut -d'?' -f2 | cut -d' ' -f3 | cut -d'_' -f3"`

When I use a file listing databases to check them by a loop, it doesn't work :
(file contains one database per line)

cat $my_file | while read line
do
(...)
active_db=`${LOCAL_BIN}/ssh -l ${my_user} ${my_service} "ps -ef | grep ora_smon | grep ${line} | sed -e \"s/ */ /g\" | cut -d'?' -f2 | cut -d' ' -f3 | cut -d'_' -f3"`
(...)
done

"it doesn't work" simply means the firt line is processed but the loop finish after it. Smilie

Thx for your lights in advance.
Rgds.
# 2  
Old 10-13-2005
nobody have idea......?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to loop with ssh

I read a file (iplist.txt) ine-by-line in a loop which has the list of all the server hostnames. With each hostname read; I do ssh and fire multiple commands to gather information about that systemas shown below. #!/bin/bash while IFS='' read -r line || ]; do echo "Text read from file:... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

While loop is causing ssh command to exit from script after first iteration.

I am trying to check multiple server's "uptime" in a loop over "ssh". When I execute multiple ssh commands with hard coded servernames script is executing fine. But when I pass server names using while loop, script is exiting after checking first server's status, why? # serverList... (8 Replies)
Discussion started by: kchinnam
8 Replies

3. UNIX for Dummies Questions & Answers

SSH Loop command each minute

Hello all :) I want to know how can i do to loop a command each minute for example ? I'm in SSH under Putty ;) Thanks you for your help :) (1 Reply)
Discussion started by: stevefigueras
1 Replies

4. Shell Programming and Scripting

While loop breaking when using "ssh" command inside

Hi , I am trying to read a list of hosts from a config file and trying to get file list from that host. For this I have used one while loop. cat "$ARCHIVE_CFG_FILE" | sed '/^$/d' | sed '/^#/d' | while read ARCHIVE_CFG do SOURCE_SERVER_NAME=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print... (2 Replies)
Discussion started by: Anupam_Halder
2 Replies

5. Shell Programming and Scripting

[solved] Process ssh command in while loop

I have a script that reads a file containing a list of server names. It's suppose to loop through the list of names and execute a command on the remote server using ssh. It processes the ssh command for the first server in the list and then exits. Here's the code: #!/bin/bash ... (2 Replies)
Discussion started by: westmoreland
2 Replies

6. Shell Programming and Scripting

while loop stops after first iteration - remote ssh exit command problem?

I have written the following script to update some Debian boxes. #!/bin/bash mxg_hosts_file="/etc/mxg/ssh-hosts" while read line ; do mxg_host="$(echo ${line} | awk -F":" '{print $1}')" mxg_port="$(echo ${line} | awk -F":" '{print $2}')" echo "Connecting and Upgrading... (3 Replies)
Discussion started by: jelloir
3 Replies

7. Shell Programming and Scripting

ssh breaks loop

Here is the smallest extract to demonstrate the problem that I experience. #!/bin/bash r=$1 while read ip do if ] ;then x=`ssh $ip echo "$ip"` else x=`echo "$ip"` fi echo $x done << EOF 192.168.8.241 192.168.8.241 EOF # Any IP with public key set (0 Replies)
Discussion started by: ivolvo
0 Replies

8. UNIX for Dummies Questions & Answers

ssh and for loop

Hi all, I am facing an issue while trying to access a for loop variable inside ssh. Can anyone please help me with what this issue is, the following is the code that I have -> IMPL_LOG_FOLDERS=(transaction_logs invalid_transaction_logs) sshg3 ftp_id@boxname << EOS for log_folder in... (5 Replies)
Discussion started by: anindyabecs
5 Replies

9. Shell Programming and Scripting

ssh inside a for loop

Hi, The requirement is to ssh to unix servers and oracle databases, to perform some monitoring activity. I'm using shell script to perfom this. I pass the server details and database to a variable ... SERVERS="SERVER1 SERVER2 SERVER3" DATABASE="DB1 DB2 DB3" for i in $SERVERS do ssh... (2 Replies)
Discussion started by: senthil3d
2 Replies

10. Shell Programming and Scripting

using ssh with a for loop

How do you do an ssh on a for statement. I have done ssh on individula lines of code before with no problems. #!/usr/bin/ksh cat server_list.txt | while read line do ssh $line "for i in `lslpp -l |grep tsm` do lslpp -Lc $i |grep -v State |tr ':' ',' |awk -F, '{print $2, "," ,... (4 Replies)
Discussion started by: din
4 Replies
Login or Register to Ask a Question