Re: [SLUG] Prblem with bash and rsync

2005-02-09 Thread Ian Wienand
On Thu, Feb 10, 2005 at 12:14:48PM +1100, Jobst Schmalenbach wrote:
> I dont quite understand why (maybe I am to much thinking of perls
> and phps eval stuff)  especially if I read bash's man page which
> does not mention anything about what you suggested.

True, it is pretty obscure.  Bash thinks of everything in tokens, and
only evaluates things once.  Usually a token is separated by a space,
but putting quotes (") around the string changes that rule.  So take
the example below

AVARIABLE="this is"
VAR="$AVARIABLE \"a string\""

bash goes through and evaluates VAR *once* according to it's rules
which, in this case leaves VAR looking like (tokens separated by a |)

|this|is|"a|string"|

you need to "re-evaluate" this to convert it to

|this|is|a string|

> Further if I consider
> 
>   --exclude \"\"Temporary Internet Files\"\"
> 
> which after the shell got it should(?) be
> 
>   --exclude \"Temporary Internet Files\"

No, bash will convert that to ""Temporary Internet Files"" which is
also wrong.

> and further if I pass a construct to other
> util they are still "kept together", eg:
> 
>   $MKDIR \"this is a spacy name\"

yes, because \"this is a spacy name\" will be evaulated by bash and
hence form a single token.

-i
[EMAIL PROTECTED]
http://www.gelato.unsw.edu.au


signature.asc
Description: Digital signature
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Re: [SLUG] Prblem with bash and rsync

2005-02-09 Thread Jobst Schmalenbach
On Thu, Feb 10, 2005 at 10:59:53AM +1100, Ian Wienand ([EMAIL PROTECTED]) wrote:
> On Thu, Feb 10, 2005 at 10:40:45AM +1100, Jobst Schmalenbach wrote:
> > COMMAND="$RSYNC -rlptgoD --delete --delete-excluded --exclude .snapshot 
> > --exclude \"Temporary Internet Files\" /$d/ $TARGET"
> > if [ $DEBUG == 1 ]; then $ECHO $COMMAND; fi
> > $COMMAND
> 
> Try using eval around this, e.g.
> 
> eval $COMMAND
> 
> You need bash to re-evaluate those quotes so it understands it should
> be one argument.


 THANK YOU ! ***


I dont quite understand why (maybe I am to much thinking
of perls and phps eval stuff)  especially if I 
read bash's man page which does not mention anything
about what you suggested.


Further if I consider

  --exclude \"\"Temporary Internet Files\"\"

which after the shell got it should(?) be

  --exclude \"Temporary Internet Files\"

and further if I pass a construct to other
util they are still "kept together", eg:

  $MKDIR \"this is a spacy name\"


But thank you, its working ...
jobst







-- 
The email address in this email is used for Mailing Lists Only. 
Please reply to the list email address ONLY, do not reply to the
email directly, it is piped into /dev/null if its not received
from a mailing list email address.

Be gentle with the earth.


 __, Jobst Schmalenbach, Technical Director
   _ _.--'-n_/   Barrett Consulting Group P/L & The Meditation Room P/L  
 -(_)--(_)=  +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Prblem with bash and rsync

2005-02-09 Thread Kevin Saenz
have you tried --exclude 'Temporary Internet Files' ?
I don't think escape characters will work the way you want in a bash script.
the other way to exclude it send it to an exclude file which will cut
down the command line to something a little more managable.


> 
> all,
> 
> I have a weird problem with a bash script and rsync (its a snapshot style 
> backup script).
> 
> Somewhere in the script I create the command:
> 
> ...
> ...
> COMMAND="$RSYNC -rlptgoD --delete --delete-excluded --exclude .snapshot 
> --exclude \"Temporary Internet Files\" /$d/ $TARGET"
> if [ $DEBUG == 1 ]; then $ECHO $COMMAND; fi
> $COMMAND
> ...
> ...
> 
> Now if I execute the command (which is displayed by the debug statement) using
> copy and paste into a XTERM it works.
> If I take out the --exclude "Temporary Internet Files" it works.
> 
> But if I run the command through the script I get:
> 
> Rsyncing /home/rsa/ /root/test/home/rsa/hourly.0
> /usr/bin/rsync -rlptgoD --delete --delete-excluded --exclude .snapshot 
> --exclude "Temporary Internet Files" /home/rsa/ /root/test/home/rsa/hourly.0
> link_stat "/usr/local/backup/Internet" failed: No such file or directory
> IO error encountered - skipping file deletion
> rsync error: some files could not be transferred (code 23) at main.c(633)
> Error rsyncing home/rsa
> 
> Now I have tried:
> 
>  --exclude \"\"Temporary Internet Files\"\"
>  --exclude Temporary\ Internet\ Files
>  --exclude \"Temporary\ Internet\ Files\"
> 
> and many other ways.
> 
> Any ideas anyone
> 
> jobst
> --
> do not email me directly, email to this account must come from mailing lists!
> all other mail is placed into /dev/null
> 
> "There are three kinds of lies: Lies, Damn lies, and statistics." - Disraeli
> 
> 
>  __, Jobst Schmalenbach, Technical Director
>_ _.--'-n_/   Barrett Consulting Group P/L & The Meditation Room P/L
>  -(_)--(_)=  +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia
> --
> SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
> Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
>
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html


Re: [SLUG] Prblem with bash and rsync

2005-02-09 Thread Ian Wienand
On Thu, Feb 10, 2005 at 10:40:45AM +1100, Jobst Schmalenbach wrote:
> COMMAND="$RSYNC -rlptgoD --delete --delete-excluded --exclude .snapshot 
> --exclude \"Temporary Internet Files\" /$d/ $TARGET"
> if [ $DEBUG == 1 ]; then $ECHO $COMMAND; fi
> $COMMAND

Try using eval around this, e.g.

eval $COMMAND

You need bash to re-evaluate those quotes so it understands it should
be one argument.

-i
[EMAIL PROTECTED]
http://www.gelato.unsw.edu.au


signature.asc
Description: Digital signature
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

[SLUG] Prblem with bash and rsync

2005-02-09 Thread Jobst Schmalenbach

all,

I have a weird problem with a bash script and rsync (its a snapshot style 
backup script).

Somewhere in the script I create the command:

...
...
COMMAND="$RSYNC -rlptgoD --delete --delete-excluded --exclude .snapshot 
--exclude \"Temporary Internet Files\" /$d/ $TARGET"
if [ $DEBUG == 1 ]; then $ECHO $COMMAND; fi
$COMMAND
...
...



Now if I execute the command (which is displayed by the debug statement) using
copy and paste into a XTERM it works. 
If I take out the --exclude "Temporary Internet Files" it works.


But if I run the command through the script I get:

Rsyncing /home/rsa/ /root/test/home/rsa/hourly.0
/usr/bin/rsync -rlptgoD --delete --delete-excluded --exclude .snapshot 
--exclude "Temporary Internet Files" /home/rsa/ /root/test/home/rsa/hourly.0
link_stat "/usr/local/backup/Internet" failed: No such file or directory
IO error encountered - skipping file deletion
rsync error: some files could not be transferred (code 23) at main.c(633)
Error rsyncing home/rsa



Now I have tried:

 --exclude \"\"Temporary Internet Files\"\"
 --exclude Temporary\ Internet\ Files
 --exclude \"Temporary\ Internet\ Files\"

and many other ways.




Any ideas anyone


jobst
-- 
do not email me directly, email to this account must come from mailing lists!
all other mail is placed into /dev/null



"There are three kinds of lies: Lies, Damn lies, and statistics." - Disraeli


 __, Jobst Schmalenbach, Technical Director
   _ _.--'-n_/   Barrett Consulting Group P/L & The Meditation Room P/L  
 -(_)--(_)=  +61 3 9532 7677, POBox 277, Caulfield South, 3162, Australia
-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html