Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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

share|improve this answer
    
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: unix.stackexchange.com/questions/144621/…, as your answer answers my original question. Thanks. – oshirowanen Jul 15 '14 at 11:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.