0

I have command called serverspec-init which prompts

Select OS type:

  1) UN*X
  2) Windows

Select number:

Now I have manually enter value 1 or 2. But I want to automate this so when i run script it automatically pick the value from variable and give input here.

Jack
  • 5,801
  • 1
  • 15
  • 20
akp
  • 1
  • 1

2 Answers2

0

I can't get my WSL installation working, for some reason, but I believe that you're looking for the $OSTYPE environment variable. On my Ubuntu machine, the value is linux-gnu and a MINGW shell gives msys.

Note that you'll need to make sure that your script is explicitly running BASH.

John C
  • 1,931
  • 1
  • 22
  • 34
0

You need the expect module:

- name: Select OS
  expect:
    command: /path/to/serverspec-init
    responses:
      Select number: "{{ OS_type_num }}"
Jack
  • 5,801
  • 1
  • 15
  • 20