#deno.run not working as expected

3 messages · Page 1 of 1 (latest)

rough iron
#

so when i run mysql --defaults-extra-file=./tmpcnf_from_f_execute_query.cnf -e "DROP DATABASE test_database" i get the correct expected error message
ERROR 1008 (HY000) at line 1: Can't drop database 'test_database'; database doesn't exist
but when i try to run this with deno


const p=Deno.run({
    cmd: `mysql --defaults-extra-file=./tmpcnf_from_f_execute_query.cnf -e "DROP DATABASE test_database"`.split(" "),
    stdout: 'piped',
    stderr: 'piped',
    stdin: 'null' 
});
await p.status();
console.log(new TextDecoder().decode(await p.output()));
console.log(new TextDecoder().decode(await p.stderrOutput()));

i just get the mysql help output
`
mysql Ver 8.0.31-0ubuntu2 for Linux on x86_64 ((Ubuntu))
Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Usage: mysql [OPTIONS] [database]
-?, --help Display this help and exit.
-I, --help Synonym for -?
--auto-rehash Enable automatic rehashing. One doesn't need to use
'rehash' to get table and field completion, but startup
and reconnecting may take a longer time. Disable with...
...more lines
`
does anyone know why?

#

i just figured out if i do it like this , it works as expected!


const p=Deno.run({
    // "bash", "-c", "ls -la"
    cmd: [
        `bash`,
        `-c`,
        `mysql --defaults-extra-file=./tmpcnf_from_f_execute_query.cnf -e "DROP DATABASE test_database"`
    ],
    stdout: 'piped',
    stderr: 'piped',
    stdin: 'null' 
});
trail sierra
#

Then close this post :)