Sponsored Content
Top Forums Shell Programming and Scripting While loop breaking when using "ssh" command inside Post 302894971 by Anupam_Halder on Friday 28th of March 2014 06:58:35 AM
Old 03-28-2014
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.
Code:
cat "$ARCHIVE_CFG_FILE" |  sed '/^$/d' | sed '/^#/d' | while read ARCHIVE_CFG
do 
    SOURCE_SERVER_NAME=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print $1 }'`
    SOURCE_FOLDER_NAME=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print $2 }'`
    LOAD_FILE_NAME=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print $3 }'`
    ARCHIVE_FOLDER=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print $4 }'` 
    ARCHIVE_DELAY=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print $5 }'`
    TEMP_SFTP_FILE="census_.$$.sftp"

    step_message="checking config variables"
    if [ "$SOURCE_SERVER_NAME" = "" ] || [ "$SOURCE_FOLDER_NAME" = "" ] || [ "$LOAD_FILE_NAME" = "" ] || [ "$ARCHIVE_FOLDER" = "" ] || [ "$ARCHIVE_DELAY" = "" ] || [ "$TEMP_SFTP_FILE" = "" ]
    then 
        log 3 "$step_message"
    else
        log 5 "$step_message"
    fi

    log 5 "================================================="
    log 5 "SOURCE_SERVER_NAME\t:\t$SOURCE_SERVER_NAME"
    log 5 "SOURCE_FOLDER_NAME\t:\t$SOURCE_FOLDER_NAME"
    log 5 "LOAD_FILE_NAME\t\t:\t$LOAD_FILE_NAME"
    log 5 "ARCHIVE_FOLDER\t\t:\t$ARCHIVE_FOLDER"
    log 5 "ARCHIVE_DELAY\t\t\t:\t$ARCHIVE_DELAY days"
    log 5 "TEMP_SFTP_FILE\t\t:\t$TEMP_SFTP_FILE"
    log 5 "================================================="
    
        #Getting file archive list from remote server
    step_message="Getting file archive list from remote server"
    FILELIST=`ssh $SOURCE_SERVER_NAME find $SOURCE_FOLDER_NAME -type f -mtime +$ARCHIVE_DELAY | grep "$SOURCE_FOLDER_NAME/$LOAD_FILE_NAME"`
    echo $?
    
done

But when I am using the ssh command inside this while loop the loop is breaking and I am not getting any more file list of next host.

Can anyone please suggest what is the issue and how to overcome this?

ARCHIVE_CFG_FILE = config file containing multiple host details
log is a function for logging.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Breaking input with "read" command

In this post, Perderabo's script says echo 05/06/25 14:15:56 | IFS=" /:" read Y1 M1 D1 h1 m1 s1 which, if I am not wrong, will break the input into Y1, M1 et al. I tried the following in my code #! /bin/ksh # per.sh typeset -R2 HOUR=00 typeset -R2 MIN=00 typeset -R2 SEC=00 ... (2 Replies)
Discussion started by: vino
2 Replies

2. Shell Programming and Scripting

Need a Command To display "echo command value in loop" in single line.

Hi I want to display "echo command value in loop" in single line. My requirement is to show the input file (test_1.txt) like the output file (test_2.txt) given below. Input file :test_1.txt a1|b1|4|5 a1|b1|42|9 a2|b2|32|25 a1|b1|2|5 a3|b3|4|8 a2|b2|14|6 Output file:test_2.txt... (2 Replies)
Discussion started by: sakthifire
2 Replies

3. Shell Programming and Scripting

Breaking "while read" also breaks the parent process

Hi, I'm a bit confused. Maybe some master can explain to me what is happening. I have a program that starts issuing output about himself loading. I want to run it in another thread but I want to wait untill it's fully loaded. Program sample: $ cat myprogram echo "loading" echo "almost... (3 Replies)
Discussion started by: chebarbudo
3 Replies

4. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

5. Shell Programming and Scripting

How to increment date using "for loop" in format MMDDYY inside the shell script?

Need to increment the date from "currentdate + 90days" inside the for loop (i=1 to i=50) (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

6. UNIX for Dummies Questions & Answers

What is the significance of sh -s in ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh?

Please can you help me understand the significance of providing arguments under sh -s in > ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh (4 Replies)
Discussion started by: Sree10
4 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Bash - How to do a "read -p" inside a while loop?

Hi there guys! I was trying to do: while read line; do if ; then read -p "Press Enter to continue..." cont=0 fi echo $line let cont++ done < file.txt However, I have read that the read -p would not work in a while loop... I was wondering if there is any other way to... (2 Replies)
Discussion started by: rplae
2 Replies

9. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies

10. UNIX for Beginners Questions & Answers

"Mv" command does not work in loop, but works manually

Hi there, this may be a beginner's error, but I've been unable to find a solution on my own and by googling, and now I am really stuck on it. I am simply trying to move directories called for example CAT_Run01.ica to a directory with the corresponding number, Run01, in the same directory. For... (2 Replies)
Discussion started by: andrevol
2 Replies
GLANCE-CONTROL(1)						      Glance							 GLANCE-CONTROL(1)

NAME
glance-control - Glance Daemon Control Helper GLANCE DAEMON START
/STOP/RELOAD HELPER SYNOPSIS glance-control [options] <SERVER> <COMMAND> [CONFPATH] Where <SERVER> is one of: all, api, registry, scrubber And command is one of: start, stop, shutdown, restart, reload, force-reload And CONFPATH is the optional configuration file to use. OPTIONS --version show program's version number and exit -h, --help show this help message and exit --config-file=PATH Path to a config file to use. Multiple config files can be specified, with values in later files taking precedence. The default files used are: [] -d, --debug Print debugging output --nodebug Do not print debugging output -v, --verbose Print more verbose output --noverbose Do not print more verbose output --log-config=PATH If this option is specified, the logging configuration file specified is used and overrides any other logging options specified. Please see the Python logging module documentation for details on logging configuration files. --log-format=FORMAT A logging.Formatter log message format string which may use any of the available logging.LogRecord attributes. Default: none --log-date-format=DATE_FORMAT Format string for %(asctime)s in log records. Default: none --log-file=PATH (Optional) Name of log file to output to. If not set, logging will go to stdout. --log-dir=LOG_DIR (Optional) The directory to keep log files in (will be prepended to --logfile) --use-syslog Use syslog for logging. --nouse-syslog Do not use syslog for logging. --syslog-log-facility=SYSLOG_LOG_FACILITY syslog facility to receive log lines --pid-file=PATH File to use as pid file. Default: /var/run/glance/$server.pid SEE ALSO o OpenStack Glance BUGS o Glance is sourced in Launchpad so you can view current bugs at OpenStack Glance AUTHOR
OpenStack COPYRIGHT
2010-present, OpenStack, LLC. 2012.1.1 March 14, 2013 GLANCE-CONTROL(1)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy