3

I'm having difficulty converting some zenity based script to use whiptail instead.

The working script looks something like this:

#!/bin/bash
xfreerdp /v:farm.company.com \
/d:company.com \
/u:$(zenity \
--entry \
--title="Username" \
--text="Enter your Username")

I am trying to convert this to use whiptail instead, but keep getting a blank screen.

This is what I have so far:

#!/bin/bash
xfreerdp /v:farm.company.com \
/d:company.com \
/u:$(whiptail \
--inputbox "Username" 10 30)

What am I doing wrong?

oshirowanen
  • 2,571
  • 15
  • 46
  • 66

1 Answers1

3

The reason the that you do not see the input box is because whiptail writes the display to stdout, which you are capturing. The result of the input is written to stderr, which you are not capturing. To make this work, you need the command substitution to capture stderr, but not stdout. You can do this with redirection:

#!/bin/bash
xfreerdp /v:farm.company.com \
/d:company.com \
/u:$(whiptail \
--inputbox "Username" 10 30 3>&1 1>&2 2>&3)
jordanm
  • 41,988
  • 9
  • 116
  • 113