Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When a string has double quotes within it, you need to escape them with <code>\</code>.</p> <pre><code>$cmd .= "-U $user_name -P $password -S $host -d master -Q \"BACKUP DATABASE [$database_name] TO DISK = N'$path'\" "; </code></pre> <p>Also, Perl lets you use other characters for quote delimiters. <code>qq</code> followed by almost any character is the same as double quotes. So you could do things like this to avoid the need of backslashes:</p> <pre><code>$cmd .= qq(-U $user_name -P $password -S $host -d master -Q "BACKUP DATABASE [$database_name] TO DISK = N'$path'" ); $cmd .= qq|-U $user_name -P $password -S $host -d master -Q "BACKUP DATABASE [$database_name] TO DISK = N'$path'" |; </code></pre> <p>And so on...</p> <p><strong>Update:</strong> How to execute a system command in Perl. There are three basic ways:</p> <pre><code>system($cmd); #Goes through the shell if shell metacharacters are detected. system(@command_and_args); #first element is the command, the rest are arguments </code></pre> <p><a href="http://perldoc.perl.org/functions/system.html" rel="nofollow"><code>system</code></a> executes a command and waits for it to return. The return value is the exit status of the program.</p> <pre><code>my @results = `$cmd`; #Always goes through shell. </code></pre> <p><a href="http://perldoc.perl.org/perlop.html" rel="nofollow">Backticks</a> execute a command and return its output. You should only use this if you actually need the output; otherwise, it is better to go with <code>system</code>.</p> <pre><code>exec $cmd; exec @command_and_args; </code></pre> <p><a href="http://perldoc.perl.org/functions/exec.html" rel="nofollow"><code>exec</code></a> is exactly like system, except that it never returns. It effectively ends your program by calling another program.</p> <p>Use the one that is most appropriate to your situation. Or in this case, since you are executing SQL, consider using the <a href="http://dbi.perl.org/" rel="nofollow">DBI</a> module. It's definitely a better approach for anything more than a couple of simple commands.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload