Re: bash question
- From: Antonio Perez <ap23563m@xxxxxxx>
- Date: Sat, 10 Oct 2009 07:45:14 -0400
Alex Samad wrote:
Hi, i have this:
RDSCHM="--remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'"
and trying this
rdiff-backup \
$RDSCHM \
$RDRM \
"$DEST/"
with sh -x i get this
+ rdiff-backup --remote-schema ''\''ssh' -i /root/.ssh/id_backup -C %s rdiff-backup '--server'\''' --remove-older-than '"10B"' --force max::/backups/test/system/
I am pretty sure you are using bash as the sh link, do 'ls -la /bin/sh' to get: /bin/sh --> /bin/bash
If it were dash the responses would be different.
Testing: set up a "test" file with:
#!/bin/sh
RDSCHM="--remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'"
echo $RDSCHM
echo "$RDSCHM"
with: bash -x test, I get:
+ RDSCHM='--remote-schema '\''ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'\'''
+ echo --remote-schema ''\''ssh' -i /root/.ssh/id_backup $'-C\302\240%s' 'rdiff-backup --server'\'''
--remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'
+ echo '--remote-schema '\''ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'\'''
--remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'
with: dash -x test, I get:
+ RDSCHM=--remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'
+ echo --remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'
--remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'
+ echo --remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'
--remote-schema 'ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'
with dash there is no « ''\''ssh' »
Also, did you notice the difference between a command on an unquoted variable and a quoted one?
+ echo --remote-schema ''\''ssh' -i /root/.ssh/id_backup $'-C\302\240%s' 'rdiff-backup --server'\'''
+ echo '--remote-schema '\''ssh -i /root/.ssh/id_backup -C %s rdiff-backup --server'\'''
Conclusion: Quoting the variable will solve your problem, as this:
rdiff-backup \
"$RDSCHM" \
"$RDRM" \
"$DEST/"
the ''\''ssh' is the confusing bit it is seperate out the ssh and the -i.
Yes, on a bash shell, but only while quoting with -x, the actual command does the right thing.
what can I do to prevent this.
Just put « $RDSCHM » inside quotes as this: « "$RDSCHM" »
My reading has lead me to IFS variable
but I don't want to start playing with this yet ! I think I am just
missing something. Hopefully the ml eyes will be able to see what i
can't
No need to....
oh and its using dash well sh
It does not really matter which shell it is, when the issue is about correct quoting of variables.
--
Antonio Perez
--
To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
with a subject of "unsubscribe". Trouble? Contact listmaster@xxxxxxxxxxxxxxxx
- Follow-Ups:
- Re: bash question
- From: Alex Samad
- Re: bash question
- References:
- bash question
- From: Alex Samad
- bash question
- Prev by Date: Re: When to expect a kernel commit in Debian stable's kernel?
- Next by Date: Re: D-Link's Shareport USB Utility
- Previous by thread: Re: bash question
- Next by thread: Re: bash question
- Index(es):
Relevant Pages
|