quoting quotes withion a (bourne shell) script line

quoting quotes withion a (bourne shell) script line

Post by Ian Didda » Sat, 21 Feb 2004 01:59:53



Hopefully an easy one but I'm tearing my hair out.

Keeping a long story short, I have a NetAPP filer with (lets say) root
access of

username : root
password : nobby'   (the end ' is supposed to be there).

Our backup software using NDMP has thism information in its
configuration.

Meanwhile I need to move data from the filer above to anothjer, for
which I would enter - on a command line from the second filer -

ndmpcopy -sa root:"nobby'" filer1:/vol/vol0/data/fred
/vol/vol0/data/fred

where the double quotes indicate that the strting within is the
password.

I can only run one such line at a time from the actual command line
and the filer permits only one login at a time.

However I can rsh commands to the filer - but my trouble here is
simply how to encompass that   root:"nobby'"   bit in a (bourne) shell
script such that the command issues the password as it should be ie
nobby'  but the shell script doesn't get confused over either the
double quotes or the single quote.

I can't change the password to something simopler #cos that will break
the backups!!

How can I acheive what I need in the script?

ie how can I script

rsh ndmpcopy -sa root:"nobby'" filer1:/vol/vol0/data/fred
/vol/vol0/data/fred

so that it runs like it would on the second filer and doesn't get
confused over the various quotes

Ian

 
 
 

quoting quotes withion a (bourne shell) script line

Post by Tarbal » Sat, 21 Feb 2004 03:21:59


**** Post for FREE via your newsreader at post.usenet.com ****

Try something like: "nobby\'" and read the manual for your shell with
regards to escaping.

Quote:> ie how can I script

> rsh ndmpcopy -sa root:"nobby'" filer1:/vol/vol0/data/fred
> /vol/vol0/data/fred

> so that it runs like it would on the second filer and doesn't get
> confused over the various quotes

--
tgz

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
                      http://www.usenet.com
Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

 
 
 

quoting quotes withion a (bourne shell) script line

Post by Carlos J. G. Duart » Sat, 21 Feb 2004 11:37:53


~>

Quote:> rsh ndmpcopy -sa root:"nobby'" filer1:/vol/vol0/data/fred
> /vol/vol0/data/fred

> so that it runs like it would on the second filer and doesn't get
> confused over the various quotes

try this:
rsh HOST 'ndmpcopy -sa root:"nobby'\''" filer1:/vol/vol0/data/fred'

--
carlos ** http://cgd.sdf-eu.org

 
 
 

quoting quotes withion a (bourne shell) script line

Post by Willia » Sun, 22 Feb 2004 05:56:42



[...]

Quote:> ie how can I script

> rsh ndmpcopy -sa root:"nobby'" filer1:/vol/vol0/data/fred
> /vol/vol0/data/fred

rsh "ndmpcopy -sa root:\"nobby'\"
filer1:/vol/vol0/data/fred/vol/vol0/data/fred"

The single quote doesn't have special meaning within double quotes,
but double quotes do, of course, so you have to escape the embedded
ones. Alternately, this'd probably work too but I don't think it's as nice:

rsh 'ndmpcopy -sa root:"'"nobby'"'
filer1:/vol/vol0/data/fred/vol/vol0/data/fred'

That looks confusing to me, but it should parse just fine. -Wm

 
 
 

1. Bourne shell dosen't seem to rescan for quotes in variables.

In an sh script --

   FOO="my_command -P\"big dog\""
   exec $FOO

my_command gets called with argv[1] = -P"big and
argv[2] = dog"

whereas I want it to be called with one argument.

The only work-around I found is to use

  sh -c $FOO

I am running SunOS 3.4.

Questions: is this universal? is this correct? is there a better
avoidance?

Benson I. Margulies                         Kendall Square Research Corp.
harvard!ksr!benson                          All comments the responsibility

2. Remote printing under FreeBSD 4.2

3. bourne shell quote

4. compiling ported newsyslog.c

5. bourne shell quoting, solaris, and ufsrestore

6. Solaris 2.3 Install Prob

7. Function arguments and quoting in Bourne-ish shells

8. debian 2.0 doesn't see scsi drive

9. quoting problem with Bourne shell

10. sh & awk: Quoting Awk Syntax in Bourne shell?

11. Quotes in quotes

12. Q: sh: Can I quote '"' in a double quoted string?

13. replace single quote to double quote with an example