Xfce Forum

Sub domains
 

You are not logged in.

#1 2015-11-22 16:29:12

daunbailo
Member
From: Italy
Registered: 2015-11-22
Posts: 72

launcher with two commands

hi
I use Xfce 4.12 on Xubuntu 15.10 and I need to launch those two commands at the same time:

sudo /etc/init.d/apache2 start
and
sudo /etc/init.d/mysql start

I've tried with 
"sudo /etc/init.d/apache2 start && sudo /etc/init.d/mysql start"
but without success.

How can I do?
Many thanks!

Offline

#2 2015-11-22 17:37:31

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,494

Re: launcher with two commands

Hello and welcome.

The problem with using sudo in a launcher command is that you won't have the ability to enter your password (if sudo is so configured). You can try:

1. Use gksu/gksudo (or pkexec) instead. These will prompt you for a password via an graphical dialog.

2. Fire up an instance of the terminal and run these commands in there - this will allow you to enter your password. A launcher command like:

xfce4-terminal -x "sudo /etc/init.d/apache2 start && sudo /etc/init.d/mysql start"

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2015-11-22 19:06:54

daunbailo
Member
From: Italy
Registered: 2015-11-22
Posts: 72

Re: launcher with two commands

I've tried the 2th but it doesn't work: two terminal window opened but no password asked

Instead a launcher with just:
sudo /etc/init.d/apache2 start
works: a terminal window is open, I insert my sudo password e the command is executed.
See my pic: http://imgur.com/y7Q4Dl5l.png

Offline

#4 2015-11-22 21:06:14

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,494

Re: launcher with two commands

Sorry, that should be "-e" if using quotes or "-x" if no quotes are used. So:

xfce4-terminal -x sudo /etc/init.d/apache2 start && sudo /etc/init.d/mysql start

...or:

xfce4-terminal -e "sudo /etc/init.d/apache2 start && sudo /etc/init.d/mysql start"

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#5 2015-11-23 19:19:31

daunbailo
Member
From: Italy
Registered: 2015-11-22
Posts: 72

Re: launcher with two commands

I've tried your 2 commands but, after I've typed the sudo password, only the first (Apache) is executed

Offline

#6 2015-11-23 21:39:36

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,494

Re: launcher with two commands

Hmmm.

Try this. Create another file with the following contents:

#!/bin/bash
sudo /etc/init.d/apache2 start
sudo /etc/init.d/mysql start

Make this file executable.

Then from your launcher, run this script via:

xfce4-terminal -x sudo /path/to/the/script

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#7 2015-11-23 21:49:13

Sideburns
Member
From: Trinidad, CO
Registered: 2011-03-30
Posts: 467
Website

Re: launcher with two commands

If you're running the script with sudo, you don't need to put it on every line inside the script as the entire thing is being run as root.


Registered Linux user #470359
Permanently recovered BOFH
Any advice in this post is worth exactly what you paid for it.

Offline

#8 2015-11-24 20:18:14

daunbailo
Member
From: Italy
Registered: 2015-11-22
Posts: 72

Re: launcher with two commands

thanks! creating another file with two commands it works. Even if I wanted to avoid creating a file for each launcher...

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.013 seconds, 8 queries executed - Memory usage: 545.97 KiB (Peak: 546.81 KiB) ]