3

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.

1
  • Please add your solution as an answer.
    – edwin
    Jul 14, 2013 at 0:38

2 Answers 2

0

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.

1
  • Thank you, rao_555, but I'm afraid things are not so easy. The command I use is
    – fbn
    Dec 27, 2011 at 13:33
0

You can use expect

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .