Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-28-2008, 01:36 AM
|
#1
|
|
LQ Newbie
Registered: Jun 2008
Posts: 18
Rep:
|
Bash script to launch a terminal window on another user's desktop
Okay, I know it's possible to have a script launch a terminal on the desktop of the person executing it -- but how about another user's desktop? I have a backup script I run nightly and I'd like it to pop up a terminal window to display the log when it's done, but the script is run as root. Is there some way to do this -- have root launch a terminal window on my desktop? (Or, failing that, some similar approach that anyone can think of?)
|
|
|
|
09-28-2008, 03:31 AM
|
#2
|
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
You probably don't want a terminal command running from your backup host with the display on the backup client. A terminal will have a limited scrollback window, and giving your clients access to your backup host is probably not ideal.
A better solution would be mail the backup log to the user.
If you must create a popup window, consider using something like zenity, which is simply a dialog popup, see this thread: http://mailman.linuxchix.org/piperma...ry/017440.html
|
|
|
|
09-28-2008, 10:59 PM
|
#3
|
|
LQ Newbie
Registered: Jun 2008
Posts: 18
Original Poster
Rep:
|
I'm sorry, maybe I wasn't clear -- this is just my personal computer, and when I said "two users" I just meant "root" and my own account. The crontab runs as root, so when I tried just using gnome-terminal to execute a command, of course nothing showed up on my desktop, since I never log in as root. When I tried it running a script as myself, it worked fine, but it doesn't work when I'm running the script as root. All the users in question are just me. Anyway, this seems easier to me than sending an email -- if I can just use less or something to display the log file, I can just glance at it and quit as long as everything looks good.
|
|
|
|
09-28-2008, 11:18 PM
|
#4
|
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
You can run a terminal window as root, and have it appear on your desktop.
You need to be sure your DISPLAY is set correctly in your script. Cron's run environment is limited, so you need to specify such things manually (environment variables, PATH, etc.).
|
|
|
|
09-29-2008, 12:12 AM
|
#5
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 14,951
|
If the logfile is world readable it could be as simple as
tail -f /path/file.log
|
|
|
|
09-29-2008, 12:43 AM
|
#6
|
|
LQ Newbie
Registered: Jun 2008
Posts: 18
Original Poster
Rep:
|
Quote:
Originally Posted by Mr. C.
You can run a terminal window as root, and have it appear on your desktop.
You need to be sure your DISPLAY is set correctly in your script. Cron's run environment is limited, so you need to specify such things manually (environment variables, PATH, etc.).
|
You're right, when I tried it from "su" it worked okay. But I changed my script, and put the line
$DISPLAY=:0.0
before the line where I launched the gnome-terminal, but it still doesn't appear to have worked.
|
|
|
|
09-29-2008, 01:16 AM
|
#7
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
You may not have authorization to access your regular users display as root.
Run:
Code:
xauth extract - $DISPLAY | sudo xauth merge -
In a terminal in your Gnome session. You are sending a cookie for your display to the root user and merging it with root's .Xauthority file.
|
|
|
|
09-29-2008, 02:01 AM
|
#8
|
|
LQ Newbie
Registered: Jun 2008
Posts: 18
Original Poster
Rep:
|
Quote:
Originally Posted by jschiwal
You may not have authorization to access your regular users display as root.
Run:
Code:
xauth extract - $DISPLAY | sudo xauth merge -
In a terminal in your Gnome session. You are sending a cookie for your display to the root user and merging it with root's .Xauthority file.
|
That was my first hypothesis, but after reading Mr. C's comment I think he was right. I did some experimenting and if I just run "sudo gnome-terminal" from a terminal, it launches a gnome-terminal that belongs to root (I can tell, because root doesn't have the same colors specified as I do), and I can launch another gnome-terminal from there and it pops up too.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 12:28 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|