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.

My bash-script is not run in a terminal, but opens a terminal at runtime to ask for user input (sudo password). I would like to tell the user in this terminal what the script is trying to do. First, here is my script:

#!/bin/bash
#This should install: Qt Linguist, lrelease

#for Qt Linguist
dpkg-query -l qt4-dev-tools
if echo $? == 0; then
 check1=1
fi

#for lrelease
dpkg-query -l qt4-default
if echo $? == 0; then
 check2=1
fi

echo $check1
echo $check2

if [ $check1 = 1 ] && [ $check2 = 1 ];then
 gnome-terminal -x sudo apt-get install qt4-dev-tools qt4-default
fi
$SHELL

This opens a terminal with this:

[sudo] password for "username": 

But I would like to have:

qt4-dev-tools and qt4-default are missing. Now trying to install.
[sudo] password for "username": 

How do I get this when starting the terminal with gnome-terminal -x?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I've had trouble passing multiple commands to gnome-terminal before, too. Something like this is what I eventually ended up using in my case:

gnome-terminal -x bash -c "echo \"qt4-dev-tools and qt4-default are missing. Now trying to install.\" && sudo apt-get install qt4-dev-tools qt4-default"

Hope it works for you.

share|improve this answer
    
Perfect, many thanks! –  user2366975 Sep 28 '13 at 11:39
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.