Skip to content

exec commands with quotes fail #196

Answered by AlexZeitler
cmeissner asked this question in Q&A
Discussion options

You must be logged in to vote

Solved it:

import { exec } from "docker-compose";

exec("maria", ["sh", "-c", "mysql --help | head -n 10"])
  .then((result) => console.log(result.out))
  .catch((e) => console.log(e));
$ yarn ts-node index.ts
yarn run v1.22.17
mysql  Ver 15.1 Distrib 10.6.5-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Usage: mysql [OPTIONS] [database]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
The following groups are read: mysql mariadb-client client client-server client-mariadb
The following options may be given as the first argument:
--print-defaults   …

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cmeissner
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants