[SATLUG] Check if stdin is empty when using socat

Paul rotering at animalcules.com
Thu Dec 4 10:35:40 CST 2014


I'm surprised you're  not getting some kind of error there (e.g. "0=0:
command not found).

It should probably read

rtval=$?



On 12/04/2014 10:05 AM, rabie at rabie.net wrote:
>  
>
> correction : $rv should read $rtval 
>
> On 2014-12-04 08:06, Rabie Khabouze wrote: 
>
>> Hello,
>>
>> 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