Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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

As part of a script I have

gnome-terminal -e "process involving another user"

Once executed this line, I have to write in the terminal 3 times the password of this user. I wonder how can I automate it, that is, without typing the password. Something as

echo "password" (3 times) | gnome-terminal -e "process involving another user"

Thank @rao_555, but I'm afraid things are not so easy. I use the command

gnome-terminal --working-directory="/var/singlecellserver/single-cell-server" \
    -e "sage -python -w 50 --untrusted-account untrusted@localhost" &

So, I don't want pass arguments to sage -python .... Once sage -python ... is launched I need to give 3 times untrusted's password. I tried

gnome-terminal --working-directory="/var/singlecellserver/single-cell-server" \
    -x sage -python -w 50 --untrusted-account untrusted@localhost $1 $1 $1 &

but no success.


The problem was related to sudo and ssh. Since it is necessary to launch the process as su, the access via ssh to the untrusted account needs the ssh keys also in the root folder.

share|improve this question
Please add your solution as an answer. – edwin Jul 14 '13 at 0:38

make a shell script and put your commands inside it, pass the password only once as argument, and inside the script use $1 to get your password,

use $1 to get your password wherever you want inside your script.

share|improve this answer
Thank you, rao_555, but I'm afraid things are not so easy. The command I use is – fbn Dec 27 '11 at 13:33

You can use expect


Should be straight forward enough, post if you need assistance.

share|improve this answer

Your Answer


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.