Search code examples
shellcommand-linepromptfreepascallazarus

How can a console command executed from a program create a graphical dialog to respond to an input prompt?


How can a Lazarus/FPC program that is executing a command via TProcess detect an input prompt and create a graphical dialog for the input?

e.g. say I execute an ssh command via TProcess which requires a password to be input - how could it detect it, prompt for it with a graphical dialog and pass it on for the command to continue?


Solution

  • Well, you have at least two choices:

    1. For "text graphics" (eg: text boxes) use whiptail or dialog and catch their output, it'll contain pure text password entered by user, example for dialog: dialog --passwordbox "Please enter password:" 10 40
    2. For X-Window graphical screen you can use zenity and grab the output, it'll contain pure text password, example: zenity --password --title "Security question: "