0

I have the following script which works:

#!/bin/bash

xfreerdp /cert-ignore /f /v:farm.company.com /d:company.com /g:rds.company.com /u:$(zenity --entry --title="Username" --text="Username") /gd:company.com /gu:$(zenity --entry --title="Username" --text="Username") /gp:$(zenity --password --title="Password" --text="Password") /p:$(zenity --password --title="Password" --text="Password")

However, it means I get prompted twice for the username and twice for the password. How can this be changed so I only have to enter the username and password once and use those credentials in both places?

The above commands needs both usernames and both password flags to be filled in. Without both sets, it does not work.

oshirowanen
  • 2,571
  • 15
  • 46
  • 66

1 Answers1

3

How about assigning it to a variable?

#!/bin/sh
user="$(zenity --entry --title="Username" --text="Username")"
pass="$(zenity --password --title="Password" --text="Password")"

xfreerdp /cert-ignore /f /v:farm.company.com /d:company.com /g:rds.company.com /u:${user} /gd:company.com /gu:${user} /gp:${pass} /p:${pass}

Just a heads up, this is not a good approach as your password and username is visible just by running ps axu

Ulrich Dangel
  • 25,079
  • 3
  • 80
  • 80
  • That works, thanks. Which approach would you recommend instead? – oshirowanen Jul 15 '14 at 10:57
  • Created a new question for a better approach here: http://unix.stackexchange.com/questions/144621/securing-a-script-a-little-more, as your answer answers my original question. Thanks. – oshirowanen Jul 15 '14 at 11:01