0

I am enclosing bash -x output which shows that the command "sudo iwlist wlan0 scan" was executed and returned expected text to terminal . The issue is - this text was not passed to whiptail msgbox option.

This fails with other "sudo ... " commands, and only with "sudo .. commands. My guess is there are non printing characters in the output text causing this issue.

sudo iwlist wlan0 scan
wlan0     Interface doesn't support scanning : Network is down

whiptail --title 'Command sudo iwlist wlan0 scan output 1400'       -   -separate-output --scrolltext --msgbox '' 17 80 10
  • I like to totally rebuild my question - is that OK? – user238756 Sep 12 '18 at 15:42
0


Whenever you are not sure, try redirecting the stdout then stderr to /dev/null.
For example, with lsusb -h > /dev/null you can still see the output, whereas with lsusb -h 2> /dev/null there's not output - therefore, the output of the help goes to stderr.
If you want to redirect stderr to stdout:
lsusb -h 2>&1
It's not obvious (at first) but what this command does is redirect stderr (file descriptor #2) to stdout (file descriptor #1).

  • lsusb -h > /dev/null you can still see the output yes I do in terminal and it locks it up I need to see it on screen "stdout" – user238756 Sep 11 '18 at 16:44
  • Actually I see all on terminal, the variable is passed to whiptail which I need to redirect. – user238756 Sep 11 '18 at 16:47
  • Well, without any additional information from your part, it's going to be hard to help you! ;) The example below works, but I don't know how well it would fit into your script: whiptail --msgbox "$(lsusb 2>&1)" 20 80 – pi0tr Sep 13 '18 at 13:05
  • What other info do you need? – user238756 Sep 13 '18 at 14:16
  • Well, I have no idea what your script does, or how it works. This makes it hard to be relevant. From what I understand, you want some variable to hold both the stdout and stderr output of the lsudb command. For example: var=$(lsusb -h 2>&1) The variable var will hold both stdout and stderr; you can then use it with whiptail: whiptail --msgbox "${var}" 20 80 – pi0tr Sep 13 '18 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy