LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 09-28-2008, 01:36 AM   #1
Excalibre
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Rep: Reputation: 0
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?)
 
Old 09-28-2008, 03:31 AM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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
 
Old 09-28-2008, 10:59 PM   #3
Excalibre
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Original Poster
Rep: Reputation: 0
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.
 
Old 09-28-2008, 11:18 PM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
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.).
 
Old 09-29-2008, 12:12 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,348

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
If the logfile is world readable it could be as simple as

tail -f /path/file.log
 
Old 09-29-2008, 12:43 AM   #6
Excalibre
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Mr. C. View Post
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.
 
Old 09-29-2008, 01:16 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.
 
Old 09-29-2008, 02:01 AM   #8
Excalibre
LQ Newbie
 
Registered: Jun 2008
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jschiwal View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
bash - how to launch a console window via script and execute commands in it? basd Programming 4 01-26-2008 08:51 PM
Trying to launch a new term window while executing a bash script in that window sfmadmax Linux - Newbie 5 12-09-2007 01:34 PM
Bash Question: Need PID of sub script at launch idoneous Linux - Newbie 4 07-19-2006 04:35 PM
How can a bash script findout the width of the terminal window alex.e.c Linux - Software 2 10-14-2004 11:20 AM
How does one launch programs 'out of process' in a terminal window? DKnight Linux - General 5 06-07-2003 10:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:19 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