exec commands with quotes fail #196
-
I need to run command with quotes with
So the command works well. I need to use This is my node code (try) to achieve the same from a script:
If I run the function I get the following error:
I try different ways to escape the quote but unfortunately I didn't found a way to run this command. How I have to escape the string to let it run? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I've been able to reproduce it using this simple setup: version: '3'
services:
maria:
image: mariadb
environment:
- MARIADB_ROOT_PASSWORD=root import { exec } from "docker-compose";
exec("maria", "sh -c 'mysql --help | head -n 10'")
.then((result) => console.log(result))
.catch((e) => console.log(e)); However I don't have a solution right now. |
Beta Was this translation helpful? Give feedback.
-
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 Print the program argument list and exit.
|
Beta Was this translation helpful? Give feedback.
-
I want to What should I do? |
Beta Was this translation helpful? Give feedback.
-
or instead of |
Beta Was this translation helpful? Give feedback.
Solved it: