Splitting string into array upon token

Posted by Gnutt on Stack Overflow See other posts from Stack Overflow or by Gnutt
Published on 2010-03-27T09:45:08Z Indexed on 2010/03/27 9:53 UTC
Read the original article Hit count: 160

Filed under:
|
|
|

I'm writing a script to perform an offsite rsync backup, and whenever the rsyncline recieves some output it goes into a single variable. I then want to split that variable into an array upon the ^M token, so that I can send them to two different logger-sessions (so I get them on seperate lines in the log).

My current line to perform the rsync

result=rsync --del -az -e "ssh -i $cert" $source $destination 2>&1

Result in the log, when the server is unavailable

ssh: connect to host offsite port 22: Connection timed out^M rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(601) [sender=3.0.7]

© Stack Overflow or respective owner

Related posts about bash

Related posts about string