[SATLUG] Check if stdin is empty when using socat

rabie at rabie.net rabie at rabie.net
Thu Dec 4 13:37:05 CST 2014


sorry, I have "while-do" not "while-then". was a typo, because I had an
if statement later in the code. 

On 2014-12-04 12:02, rabie at rabie.net wrote: 

> Sure I was getting the error, I switched it to rv=$? and the error went
> away. 
> first time seeing while then ? 
> I have even tried " while [ !EOF ] " it did not detect and end of file
> from the other server. 
> Rabie 
> On 2014-12-04 09:46, Paul wrote:
>> Another problem is that your while loop should read while [ <cond>]; do rather than while [ <cond>]; then You should be getting error messages. Yet another is that you're setting $rtval to 0 then checking to see if it's not 0 before entering the loop. You'll never exectute the code in the loop that way. -Paul On 12/04/2014 10:05 AM, rabie at rabie.netwrote: correction : $rv should read $rtval On 2014-12-04 08:06, Rabie Khabouze wrote: kHello, I m using socat to transfer file from one server to another. I have the following command running in the background on one of the servers socat tcp-l:8989,reuseaddr,fork exec:/opt/scripts/printdoc.sh and in printdoc.sh I have the following code : #!/bin/bash now=$date +"%Y%m%d-%H-%s") filename="spdoc.$now.txt" rtval=0 while [ $rtval != 0 ]; then cat - >> /opt/scripts/docs/$filename $rv=$? done Do something else down here .. Now when I cat a file from the other server, my script triggers but it never goes outside the while loop, somehow it is not
reading the exit code $? it should be grater than 0 any thoughts ? Thanks Rabie


More information about the SATLUG mailing list