[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Hi how to escaping under ` ` in sh



On Wed, Apr 21, 2010 at 02:40:54PM +0530, Siju George wrote:
> On Wed, Apr 21, 2010 at 2:31 PM, Tzafrir Cohen <tzafrir@cohens.org.il> wrote:
> >
> > You got the output of 'show databases'. You then consider it a shell
> > command and try to excute it. Why would you want to do that? What do you
> > want to do with that output?
> >
> 
>  mysql -u root -pmy\$ql -N -B -e 'show databases'
> 
> works
> 
> I was to get the script
> 
> #!/bin/sh
> for DB in `mysql -u root -pmy\$qlPW -N -B -e 'show databases'`; \
>    do echo $DB; \
>    mysqldump -u root -pmy\$qlPW -e $DB > /var/mysql-1hBak/$DB.sql; \

mysqldump --all-databases ?

> done

$ mysql mysql -e 'show databases'
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test123            |
+--------------------+

$ mysql mysql --batch -e 'show databases'
Database
information_schema
mysql
test123

$ mysql mysql --batch --silent -e 'show databases'
information_schema
mysql
test123

> 
> to work.
> 
> > BTW: I would suggest that you actually use a .my.cnf to hold the
> > password, otherwise the password is available in e.g. the output of 'ps
> > auxww'
> >
> 
> yes I would eventually do that but even then you need to escape the $ inside ``

In that case, the '$' is not part of the command-line, and hence no need
to escape it.

-- 
Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
tzafrir@debian.org    |                    | friend


Reply to: