0

I have a shell script

#! /bin/bash 

command='echo "hello world" '
timeout=10
cli_raw_output="$(timeout ${timeout} "${command}" 2>&1)" 
echo "$cli_raw_output"

Here when I execute, it's giving the error as

timeout: failed to run command `echo "hello world" ': No such file or directory

I understand that it's treating 'echo "hello world"' as a single word. But in these cases how do I execute it?

I can't remove the quotes around 'command' variable as I have to treat 'hello world'(it's a requirement) as a single word(not necessary in this echo case though).

Prajwal
  • 563
  • 7
  • 22
  • you should use this=> cli_raw_output=$(timeout $timeout $command 2>&1) instead of=> cli_raw_output="$(timeout ${timeout} "${command}" 2>&1)" – Akhil Feb 11 '19 at 07:04
  • @AkhilJalagam Same issue, it's sending "hello and world" instead of "hello world" – Prajwal Feb 14 '19 at 17:06

0 Answers0