LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-30-2010, 09:30 PM   #1
djstava
LQ Newbie
 
Registered: May 2010
Posts: 4

Rep: Reputation: 0
notify-send not work as CGI script?


I write a cgi script in python just send a notification command,but that can not work for me.

Code:
#!/usr/bin/env python
#-*-coding=utf-8-*-

import cgi
import os

print 'Content-Type:text/html\n\n'

os.system("notify-send 'hello'")

And
Code:
djstava@Gateway:~/test$ notify-send 'hello'
is OK.

This is the error.
Code:
djstava@Gateway:/tmp$ cat notify-error 
libnotify-Message: Unable to get session bus: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.


** (notify-send:4642): CRITICAL **: dbus_g_proxy_connect_signal: assertion `DBUS_IS_G_PROXY (proxy)' failed

** (notify-send:4642): CRITICAL **: dbus_g_proxy_connect_signal: assertion `DBUS_IS_G_PROXY (proxy)' failed

** (notify-send:4642): CRITICAL **: dbus_g_proxy_call: assertion `DBUS_IS_G_PROXY (proxy)' failed
libnotify-Message: Unable to get session bus: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.


** (notify-send:4642): CRITICAL **: dbus_g_proxy_disconnect_signal: assertion `DBUS_IS_G_PROXY (proxy)' failed

** (notify-send:4642): CRITICAL **: dbus_g_proxy_disconnect_signal: assertion `DBUS_IS_G_PROXY (proxy)' failed

(notify-send:4642): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
 
Old 05-30-2010, 10:55 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
I can't actually see what is in your CODE tags because I am on my phone, but the problem is almost certainly the fact that the script is not being executed as the user with the X session, but rather the user your web server is setup to run under.

The problem is, you certainly don't want the web server running under your normal user account either.
 
Old 05-30-2010, 11:10 PM   #3
djstava
LQ Newbie
 
Registered: May 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by MS3FGX View Post
I can't actually see what is in your CODE tags because I am on my phone, but the problem is almost certainly the fact that the script is not being executed as the user with the X session, but rather the user your web server is setup to run under.

The problem is, you certainly don't want the web server running under your normal user account either.
Yes,I change the apache2's default user www-data to my system user djstava,and it works,ONLY need the $DISPLAY.Just like this,
Code:
os.system("DISPLAY=:0.0; notify-send 'hello'")
Thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Libnotify and notify-send problems J_Humphrey Slackware 8 07-27-2010 04:43 PM
using notify-send ashikahamed Ubuntu 0 05-02-2008 06:09 AM
why this simple cgi script doesnot work ? . adam_blackice Programming 4 04-04-2007 10:50 AM
#! does not seem to work in cgi-bin?? (script execution) servnov Linux - General 6 12-06-2004 07:23 AM
CGI script problem: Send/Expect command echo on webpage rajatgarg Programming 2 07-11-2004 04:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 12:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration