Display terminal command result in Desktop notification

Clash Royale CLAN TAG#URR8PPP up vote
5
down vote
favorite
I need to display the result of a terminal command in notification.
Notifications can be triggered by running:
notify-send "Notification message"
The command I have is:
sudo /opt/lampp/xampp start
which shows the following result in terminal:
Starting XAMPP for Linux 5.6.20-0...
XAMPP: Starting Apache...already running.
XAMPP: Starting MySQL...already running.
XAMPP: Starting ProFTPD...already running.
I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.
Thanks!
command-line gnome-terminal notification notify-send
add a comment |Â
up vote
5
down vote
favorite
I need to display the result of a terminal command in notification.
Notifications can be triggered by running:
notify-send "Notification message"
The command I have is:
sudo /opt/lampp/xampp start
which shows the following result in terminal:
Starting XAMPP for Linux 5.6.20-0...
XAMPP: Starting Apache...already running.
XAMPP: Starting MySQL...already running.
XAMPP: Starting ProFTPD...already running.
I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.
Thanks!
command-line gnome-terminal notification notify-send
add a comment |Â
up vote
5
down vote
favorite
up vote
5
down vote
favorite
I need to display the result of a terminal command in notification.
Notifications can be triggered by running:
notify-send "Notification message"
The command I have is:
sudo /opt/lampp/xampp start
which shows the following result in terminal:
Starting XAMPP for Linux 5.6.20-0...
XAMPP: Starting Apache...already running.
XAMPP: Starting MySQL...already running.
XAMPP: Starting ProFTPD...already running.
I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.
Thanks!
command-line gnome-terminal notification notify-send
I need to display the result of a terminal command in notification.
Notifications can be triggered by running:
notify-send "Notification message"
The command I have is:
sudo /opt/lampp/xampp start
which shows the following result in terminal:
Starting XAMPP for Linux 5.6.20-0...
XAMPP: Starting Apache...already running.
XAMPP: Starting MySQL...already running.
XAMPP: Starting ProFTPD...already running.
I want this result to be displayed in notification just like "Notification message" is displayed with notify-send.
Thanks!
command-line gnome-terminal notification notify-send
command-line gnome-terminal notification notify-send
edited Apr 19 at 21:22
Zanna
48k13119228
48k13119228
asked Apr 14 at 8:28
M. Zeeshan
283
283
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
8
down vote
accepted
In most cases you can use notify-send with command substitution $(). For example:
notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"
Inside a scrip you can use a function to wrap the entire output:
#!/bin/bash
main() echo "Line 1"; echo "Line 2"; echo "Line 3";
notify-send "Script output" "$(main)"
If you need to run that function with sudo:
notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
accepted
In most cases you can use notify-send with command substitution $(). For example:
notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"
Inside a scrip you can use a function to wrap the entire output:
#!/bin/bash
main() echo "Line 1"; echo "Line 2"; echo "Line 3";
notify-send "Script output" "$(main)"
If you need to run that function with sudo:
notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"
add a comment |Â
up vote
8
down vote
accepted
In most cases you can use notify-send with command substitution $(). For example:
notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"
Inside a scrip you can use a function to wrap the entire output:
#!/bin/bash
main() echo "Line 1"; echo "Line 2"; echo "Line 3";
notify-send "Script output" "$(main)"
If you need to run that function with sudo:
notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"
add a comment |Â
up vote
8
down vote
accepted
up vote
8
down vote
accepted
In most cases you can use notify-send with command substitution $(). For example:
notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"
Inside a scrip you can use a function to wrap the entire output:
#!/bin/bash
main() echo "Line 1"; echo "Line 2"; echo "Line 3";
notify-send "Script output" "$(main)"
If you need to run that function with sudo:
notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"
In most cases you can use notify-send with command substitution $(). For example:
notify-send "XAMP Start" "$(sudo /opt/lampp/xampp start)"
Inside a scrip you can use a function to wrap the entire output:
#!/bin/bash
main() echo "Line 1"; echo "Line 2"; echo "Line 3";
notify-send "Script output" "$(main)"
If you need to run that function with sudo:
notify-send "Script output" "$(sudo bash -c "$(declare -f main); main")"
edited Apr 15 at 7:07
answered Apr 14 at 8:42
pa4080
12.2k52255
12.2k52255
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1024904%2fdisplay-terminal-command-result-in-desktop-notification%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password