Article View: pl.comp.lang.perl
Article #51706Re: system() i mysqldump
From: Bartosz Feński aka fEnIo
Date: Wed, 09 Dec 2009 21:49
Date: Wed, 09 Dec 2009 21:49
51 lines
3112 bytes
3112 bytes
W artykule Adam Osuchowski napisał(a):
>> No i próbuję sklecić wywołanie system():
>>
>> system($dump, '-h', $cfg->val('baza', 'host'),
>> '-u', $cfg->val('baza', 'user'),
>> '-p', $cfg->val('baza', 'password'),
>> $cfg->val('baza', 'db'),
>> '> /home/backups/baza.sql');
>>
>> No i skończyłem z tym, że pyta mnie o hasło.
>> Jak podmienię 3 linijkę na '-pnieistotne' to działa, ale chciałbym
>> to jednak brać z owego configa. Czyli przekazywanie argumentów
>> w taki sposób dowala tam spację, której mysqldump nie lubi. Da się to inaczej
>> wywołać czy mam sobie ten argument zbudować najpierw gdzieś na boku?
>>
>> Poza tym gdy już mam wklepane owe '-pnieistotne' to z kolei kończę z:
>>
>> mysqldump: Couldn't find table: " > /home/backups/baza.sql"
>>
>> Czyli mój znaczek ">" jest totalnie zlewany, a raczej jakoś cudacznie
>> przekazywany do shella, że ten go nie traktuje jako przekierowanie.
>> Jak to obejść?
>
> Przeczytać manual do funkcji system():
>
> If there is more than one argument in LIST, or if LIST is an array
> with more than one value, starts the program given by the first element
> of the list with arguments given by the rest of the list. If there is
> only one scalar argument, the argument is checked for shell metacharacters,
> and if there are any, the entire argument is passed to the system's command
> shell for parsing (this is "/bin/sh -c" on Unix platforms, but varies on
> other platforms).
>
> Innymi słowy, jak chcesz, żeby działały shellowe znaki specjalne,
> przekaż do funkcji system() jeden argument.
Grrr... no czytałem to i jakoś mi do łba owe "if there is only one scalar
argument" inaczej właziło :/
Sorry. Teraz jak to czytam to rzeczywiście jakoś źle sobie to
zinterpretowałem. Dzięki.
pozdr,
fEnIo
--
,''`. Bartosz Fenski | mailto:fenio@debian.org | pgp:0x13fefc40 | irc:fEnIo
: :' : 32-050 Skawina - Glowackiego 3/15 - malopolskie v. - Poland
`. `' phone:+48602383548 | proud Debian maintainer and user
`- http://fenski.pl | xmpp:fenio@jabber.org | rlu:172001
Technical Details
Message-ID:
<slrnhi06qg.tv9.fenio@komputer.fenia.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!komputer.fenia.pl!not-for-mailReferences:
<slrnhi00sv.tv9.fenio@komputer.fenia.pl> <20091209201952.6b8b4567@polsl.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!komputer.fenia.pl!not-for-mail From: Bartosz Feński aka fEnIo <fenio@debian.org> Newsgroups: pl.comp.lang.perl Subject: Re: system() i mysqldump Date: Wed, 9 Dec 2009 22:49:04 +0100 Organization: Front Wyzwolenia Krasnali Ogrodowych Lines: 51 Message-ID: <slrnhi06qg.tv9.fenio@komputer.fenia.pl> References: <slrnhi00sv.tv9.fenio@komputer.fenia.pl> <20091209201952.6b8b4567@polsl.pl> Reply-To: fenio@debian.org NNTP-Posting-Host: h091203132213.nephax.net Mime-Version: 1.0 X-Trace: news.onet.pl 1260395354 28158 91.203.132.213 (9 Dec 2009 21:49:14 GMT) X-Complaints-To: niusy@onet.pl NNTP-Posting-Date: Wed, 9 Dec 2009 21:49:14 +0000 (UTC) User-Agent: slrn/pre1.0.0-11 (Linux) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit