4

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?

Glutanimate
  • 21,393
user2366975
  • 717
  • 1
  • 10
  • 19

1 Answers1

9

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.

Glutanimate
  • 21,393