Sponsored Content
Top Forums Shell Programming and Scripting While loop is not reading next line in the file when IF condition is used. Post 302600003 by agama on Sunday 19th of February 2012 10:39:08 PM
Old 02-19-2012
A while loop with redirection or piped input reads from stdin. Ssh by default also reads stdin and ends up reading the remainder of the data intended for the while.

Add -n to your ssh command to prevent it from reading from stdin.

Last edited by agama; 02-19-2012 at 11:40 PM.. Reason: clairity
This User Gave Thanks to agama For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading from a specific line in a loop

Hello All, Request you to let me know how to do the below urgently.. Requirement File A Contains: for i in file A DEV1 DEV5 STG1 STG5 File B Contains: for j in file B DEV1 DEV5 STG1 STG5 (3 Replies)
Discussion started by: kaushikraman
3 Replies

2. Shell Programming and Scripting

while loop not reading last line

hi all, i have a while loop which i am using to read lines into an array: k=0 exec 10<file while read LINE <&10; do ARRAY=$LINE ((k++)) done exec 10>&- echo ${ARRAY} for some reason when i display the array it is not showing the last row in the file. any help appreciated. (1 Reply)
Discussion started by: npatwardhan
1 Replies

3. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

4. Shell Programming and Scripting

Read file using while loop not reading last line

I have written a script to read the file line by line. It is reading and printing the lines. But it is coming out of loop before reading last line. So I am not able to print last line. How do I solve it. (6 Replies)
Discussion started by: dgmm
6 Replies

5. Shell Programming and Scripting

Recursive search for string in file with Loop condition

Hi, Need some help... I want to execute sequence commands, like below test1.sh test2.sh ...etc test1.sh file will generate log file, we need to search for 'complete' string on test1.sh file, once that condition success and then it should go to test2.sh file, each .sh scripts will take... (5 Replies)
Discussion started by: rkrish123
5 Replies

6. Shell Programming and Scripting

Reading line in while loop

Hello Team, i have to read line by line in a while loop, and the input file has:. # The script will start cppunit test application to run unit tests. -LD_LIBRARY_PATH=$CPPUNIT_HOME/lib:\ +LD_LIBRARY_PATH=$VOBTAG/SS_UnitTest/lib:\ $VOBTAG/SS_BFD/BFDSCLI/build:\ ... (7 Replies)
Discussion started by: chandana hs
7 Replies

7. Shell Programming and Scripting

Reading line by line from live log file using while loop and considering only those lines start from

Hi, I want to read a live log file line by line and considering those line which start from time stamp; Below code I am using, which read line but throws an exception when comparing line that does not contain error code tail -F /logs/COMMON-ERROR.log | while read myline; do... (2 Replies)
Discussion started by: ketanraut
2 Replies

8. Shell Programming and Scripting

Problem with while loop reading every line of a text file

Hello, I'm using RHEL 5.1 with bash. How to handle "read" inside while loop reading every line? Please see below: # cat /tmp/passwd_sample CARRJ12:qVSn4ja4mFA72,..:20021:125:JULIAN CARR:/home/everyone:/bin/bash HERCOT01:NK/3j2ZB4ZC7Q:20022:125:TOM HERCOCK:/home/everyone:/bin/bash... (4 Replies)
Discussion started by: reddyr
4 Replies

9. Windows & DOS: Issues & Discussions

Batch file loop and increment value for condition

I am trying to have the below batch file do following two things: 1. only allow the values YES,yes,Y,y, or NO,no,N,n 2. increment the counter %var1 only if answer to question 2 is "y" and not able to get the syntax correct. If %var1%=1 then I am trying to display function :end. Thank you :).... (0 Replies)
Discussion started by: cmccabe
0 Replies
uncat(1)						      General Commands Manual							  uncat(1)

NAME
uncat - continuously reads stdin, splits up the data either by timeout or number of bytes read to process it SYNOPSIS
uncat [-vo] [-t seconds] [-s size] prog DESCRIPTION
uncat continuously reads stdin and repeatedly processes the data either after seconds timeout or maximal number of bytes size read. To process the data, uncat starts prog and feeds the data into prog's standard input. prog's standard output is redirected to standard error. uncat never writes to standard output. prog consist of one or more arguments. If prog exits non-zero, uncat prints an error message, discards the data and continues to read stdin. Note that uncat is not crash proof. uncat is used to run the socklog-notify service. OPTIONS
-v verbose. Print verbose messages to stderr. -o once. Exit on end of input. Normally uncat continues waiting for data on standard input, even on end of file. -t seconds timeout. Set the timeout to seconds seconds. Default is 300. -s size Set the maximal number of bytes to size. Default is 1024. SIGNALS
If uncat receives a TERM signal, it starts to process the data in memory and exits as soon as possible. uncat also does this on end of input if the -o option was given. EXIT CODES
uncat returns 0 after receiving a TERM signal. uncat returns 111 on error. SEE ALSO
socklog(8), socklog-conf(8), sv(8), runsv(8), svlogd(8), tryto(1) http://smarden.org/socklog/ http://smarden.org/runit/ AUTHOR
Gerrit Pape <pape@smarden.org> uncat(1)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy