Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: System command using array and pipe

by philipbailey (Chaplain)
on Jun 06, 2011 at 20:08 UTC ( #908359=note: print w/replies, xml ) Need Help??


in reply to Re^4: System command using array and pipe
in thread System command using array and pipe

The only issue that cannot be resolved by single quoting relevant parts of the command line is of escaping single quotes. Either do this manually, or do something simple like this:

s#'#'\\''#g for ($password, $path); system("mysqldump --add-drop-table -uroot -p'$password' mydatabase | g +zip -9c > '$path'");

Update: s/// command corrected as per ikegami.

Replies are listed 'Best First'.
Re^6: System command using array and pipe
by ikegami (Pope) on Jun 06, 2011 at 20:17 UTC
    I prefer
    my ($passwd_lit, $path_lit) = map text_to_shell_lit, $passwd, $path; system("mysqldump --add-drop-table -uroot -p$passwd_lit mydatabase | g +zip -9c > $path_lit");
    to
    my $passwd_lit = $passwd; my $path_lit = $path; s#'#'\\''#g for $passwd_lit, $path_lit; system("mysqldump --add-drop-table -uroot -p'$passwd_lit' mydatabase | + gzip -9c > '$path_lit'");

    but to each his own.

    By the way, your quoting was buggy. "\" is not special in sh single-quoted literals.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://908359]
help
Chatterbox?
[Discipulus]: problem scrolling even main page..;=(
[LanX]: holli -> Good Intentions: Wikisyntax for the Monastery
[LanX]: monklinks are automatically converted ...
[LanX]: On another node, I just saw yesterday that the everything engine supports auto-paragraph whithout the need to type <p>
LanX i.e. the newest everything engine

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-11-20 19:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (291 votes). Check out past polls.

    Notices?