Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 trusted_db.py -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 trusted_db.py -w 50 --untrusted-account untrusted@localhost $1 $1 $1 &

but no success.

SOLVED

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
add comment

2 Answers 2

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
add comment

You can use expect

See http://www.linuxjournal.com/article/3065

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

share|improve this answer
add comment

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.