OpenVZ Forum


Home » Mailing lists » Users » problems with vzctl init logging patch
AW: AW: problems with vzctl init logging patch [message #28284 is a reply to message #28259] Thu, 13 March 2008 07:43 Go to previous messageGo to previous message
Dietmar Maurer is currently offline  Dietmar Maurer
Messages: 52
Registered: March 2007
Member
> Adding a check makes sense. But first -- why do you need perl 
> at all? Is there something that can't be done in shell?
> >   

I just remembered why I hate shell programming ;-)

Please can someone tell me how to do a binary read with a shell. In perl
I simple do:

while (my $len = sysread (LOGFIFO, $buf, 4096)) {
  syswrite (LOGFILE, $buf);	
}

How to do that with a shell script? I first tried:

cat <$logfifo >>$logfile

But that spans a new process, and I do not want that. 

Using builtin commands only:

while [ 1 ]; do
        read line || break
        echo $line
done < $logfifo >>$logfile

Works, but always waits for whole lines (we want to read/write
immeniately instead)

The following code works for bash, but not for other shells:

while [ 1 ]; do
        # -n is not available everywhwere (i.e. dash)
        read -n 1 data || break
        if [ -z $data ]; then
            echo
        else
            echo -n $data
        fi
done < $logfifo >>$logfile

Any Ideas?

- Dietmar
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: usage of swap on host server
Next Topic: State of 2.6.24
Goto Forum:
  


Current Time: Wed Aug 20 05:45:47 GMT 2025

Total time taken to generate the page: 0.18375 seconds