-1

I want to open terminal with multiple instances of same server. For example, csshX server1 server1 server1

I'm trying to assign the formatted list of strings to single variable and use it in csshX.

#!/usr/local/bin/fish
set nmdat (echo 'server1 ' | string repeat -n (echo $countofinstance))
csshX $nmdat

But, this isn't helping. I have also tried

csshX (echo 'server1 ' | string repeat -n (echo $countofinstance))

This isn't working as well.

Ram
  • 103
  • 6

1 Answers1

3

(echo $somevariable) can be written more simply as $somevariable

Try this: it should pass count individual arguments to the command:

set server server1
csshX (string repeat -n $count -N $server\n)

Demo:

$ set count 5
$ set string foo

$ bash -c 'echo $#; printf \'%s\\n\' "$@"' bash (string repeat -n $count "$string ")
1
foo foo foo foo foo

$ bash -c 'echo $#; printf \'%s\\n\' "$@"' bash (string repeat -n $count $string\n)
6
foo
foo
foo
foo
foo

# with an extra newline

$ bash -c 'echo $#; printf \'%s\\n\' "$@"' bash (string repeat -n $count -N $string\n)
5
foo
foo
foo
foo
foo
glenn jackman
  • 238,783
  • 38
  • 220
  • 352