Sponsored Content
Top Forums UNIX for Advanced & Expert Users "while read ..." loop exiting after reading only one record Post 302391778 by twk on Tuesday 2nd of February 2010 01:09:40 PM
Old 02-02-2010
"while read ..." loop exiting after reading only one record

Greeting,

The following script completes after reading only one record from the input file that contains many records. I commented out the "ssh" and get what I expect, an echo of all the records in the input.txt file. Is ssh killing the file handle?

On the box "uname -a" gives "SunOS Server01 5.10 Generic_127127-11 sun4u sparc SUNW,Sun-Fire-V490".



Code:
#!/bin/ksh
\rm -f /tmp/x/*
let i=0
IFS=,
while read server dir; do
let i=i+1
echo "Record $i: ${server} ${dir}"
dir_=`echo ${dir} | tr "[/]" "[_]"`
ssh ${server} find ${dir} -follow  >/tmp/x/${server}${dir_}.txt
es=$?
echo "exit status = $es\n"
done < input.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to request a "read" or "delivered" receipt for mails

Dears, I've written a script which allows me to send mails in different formats with different attaches. Now I still want to add a feature to this script. My users would like to be able to receive a "read" or "delivered" receipt for their mails. The script send mails on behalve of an specific... (1 Reply)
Discussion started by: plelie2
1 Replies

2. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

3. Shell Programming and Scripting

"Odd" behavior exiting shell script

Is it normal behavior for a shell script that terminates to terminate its parent shell when executed with the "." option? For example, if I have the example script (we'll name it ex.sh): #!/bin/sh if then echo "Bye." exit 2 fi And I execute it like this: >./ex.sh It... (6 Replies)
Discussion started by: DreamWarrior
6 Replies

4. Shell Programming and Scripting

Purpose of "read" and "$END$" in ksh ?

Hi, Could anyone please shed some light on the following script lines and what is it doing as it was written by an ex-administrator? cat $AMS/version|read a b verno d DBVer=$(/usr/bin/printf "%7s" $verno) I checked that the cat $AMS/version command returns following output: ... (10 Replies)
Discussion started by: dbadmin100
10 Replies

5. Shell Programming and Scripting

Read from "list1" and list matches in "list2"

I want to print any matching IP addresse in List1 with List 2; List 1 List of IP addresses; 161.85.58.210 250.57.15.129 217.23.162.249 74.76.129.101 30.221.177.237 3.147.200.59 170.58.142.64 127.65.109.33 150.167.242.146 223.3.20.186 25.181.180.99 2.55.199.32 (3 Replies)
Discussion started by: lewk
3 Replies

6. Ubuntu

What is solution for this error "tar: Exiting with failure status due to previous errors"?

Does anyone know what is solution for this error ?tar: Exiting with failure status due to previous errors from last 3 days I am trying to take backup of home/user directory getting again and again same error please anyone give me solution (8 Replies)
Discussion started by: Akshay Hegde
8 Replies

7. Solaris

Solaris 10 "Exiting (caught signal 11)"

I get an error after the initializing screen. I am using a DVD/ROM to boot up the installation on a Dell Inspiron 1520. Segmentation fault - core dumped. I have tried to restart multiple times. Please help (1 Reply)
Discussion started by: Jimasaurus
1 Replies

8. 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

9. 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

10. 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
SoNotList(3)							       Coin							      SoNotList(3)

NAME
SoNotList - The SoNotList class is a list of SoNotRec notification records. SYNOPSIS
#include <Inventor/misc/SoNotification.h> Public Member Functions SoNotList (void) SoNotList (const SoNotList *nl) void append (SoNotRec *const rec) void append (SoNotRec *const rec, SoField *const field) void append (SoNotRec *const rec, SoEngineOutput *const engineout) void setLastType (const SoNotRec::Type type) SoNotRec * getFirstRec (void) const SoNotRec * getLastRec (void) const SoNotRec * getFirstRecAtNode (void) const SoField * getLastField (void) const SoEngineOutput * getLastEngineOutput (void) const uint32_t getTimeStamp (void) const void print (FILE *const file=stdout) const Detailed Description The SoNotList class is a list of SoNotRec notification records. Constructor &; Destructor Documentation SoNotList::SoNotList (void) Initialize list. SoNotList::SoNotList (const SoNotList *nl) Copy constructor. Does a bitwise copy of the nl object (no duplication of list elements). Member Function Documentation void SoNotList::append (SoNotRec *constrec) Append rec notification source to the list. void SoNotList::append (SoNotRec *constrec, SoField *constfield) Append rec notification source to the list, setting field as the last field having been influenced by the notification process. void SoNotList::append (SoNotRec *constrec, SoEngineOutput *constengineout) Append rec notification source to the list, setting engineout as the last engine output field having been influenced by the notification process. void SoNotList::setLastType (const SoNotRec::Typetype) Set the type of the last notification record in the list. SoNotRec * SoNotList::getFirstRec (void) const Returns the first record in the list. SoNotRec * SoNotList::getLastRec (void) const Returns the last record in the list. SoNotRec * SoNotList::getFirstRecAtNode (void) const Returns the first record in the list which is derived from SoBase. SoField * SoNotList::getLastField (void) const Returns the last field touched by notification. SoEngineOutput * SoNotList::getLastEngineOutput (void) const Returns the last engine output field touched by notification. uint32_t SoNotList::getTimeStamp (void) const Returns the time stamp when the notification started. void SoNotList::print (FILE *constfile = stdout) const Dump contents of list from tail record and backwards. Only available if compiled with debug information on. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoNotList(3)
All times are GMT -4. The time now is 04:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy