How to use arguments with spaces and dots when using $os.cmd() to execute shell commands in pb_hooks? #4945
-
Hello, I am trying to get an output from this: nmcli --terse --color no --mode multiline --show-secrets --wait 10 --fields ipv4.method connection show "Wired connection 1" Using hook: const arg_nmcli = ['--terse', '--color', 'no', '--mode', 'multiline', '--show-secrets', '--wait', '10'];
const connection = 'Wired connection 1';
const result = String.fromCharCode(...$os.cmd('nmcli', ...arg_nmcli, ...['--fields', 'ipv4.method', 'connection', 'show', `"${connection}"`]).output());
console.log(result); I got an error. Any suggestions? |
Beta Was this translation helpful? Give feedback.
Answered by
ganigeorgiev
May 17, 2024
Replies: 1 comment 5 replies
-
What is the error? In general the above double array spread/expansion looks weird but I guess it should work. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I also just noticed that you are inserting extra double quotes around the "Wired connection 1" string. Try to remove them as these quotes are usually needed only for the shell to properly split/extract the args.