LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 10-30-2007, 04:37 PM   #1
Casket
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Slackware 10.1 - 2.4.29
Posts: 79

Rep: Reputation: 15
How to close terminal window when launching app from command line


Hi all,

I've created a couple of shell scripts (using sudo) and linked a desktop icon to them to allow my users to be able to launch 'root only' applications. Whenever it does this though a terminal session always stays open in another windows (if you press CTRL+C it will close the application).

Is there anyway to prevent this from happening and just have the application active?

Thanks
 
Old 10-30-2007, 04:50 PM   #2
Dinithion
Member
 
Registered: Oct 2007
Location: Norway
Distribution: Slackware 13.37
Posts: 436

Rep: Reputation: 56
You could open them with screen and detach then with ctrl+ad
 
Old 10-30-2007, 06:43 PM   #3
Casket
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Slackware 10.1 - 2.4.29
Posts: 79

Original Poster
Rep: Reputation: 15
Is there a simple way to do this? The users are fairly compute illiterate and quite simply would bitch and moan if any additional steps needed to be taken.
 
Old 10-30-2007, 07:16 PM   #4
Casket
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Slackware 10.1 - 2.4.29
Posts: 79

Original Poster
Rep: Reputation: 15
Okay I figured out a semi-solution:

The icon on the desktop calls upon /usr/bin/pptp.sh which contains the following:

Code:
#!/bin/sh
sudo /usr/sbin/pptpconfig
The sudoers file allows the user to run this command only without a password. If i change the shell script to:

Code:
#!/bin/sh
sudo nohup /usr/sbin/pptpconfig
and add /usr/bin/nohup to the sudoers file, it allows the user to open the application up and close the terminal window without closing down the application.

If this can be automated to close down the terminal window when the program is launched it would be a great solution. I have tried appending | exit on to the end and putting exit in a new line in the shell script but it does not work.

Thanks
 
Old 10-31-2007, 06:52 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5
Posts: 16,086

Rep: Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995Reputation: 1995
how about backgrounding it as well eg

Code:
#!/bin/sh
sudo nohup /usr/sbin/pptpconfig &
exit
 
Old 10-31-2007, 06:21 PM   #6
Casket
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Slackware 10.1 - 2.4.29
Posts: 79

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by chrism01 View Post
how about backgrounding it as well eg

Code:
#!/bin/sh
sudo nohup /usr/sbin/pptpconfig &
exit
Hi Chrism,

That didn't work. When the desktop icon is double clicked a terminal window appears for a breif second and then closes without launching the application.
 
Old 11-01-2007, 01:39 AM   #7
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,495

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
Casket -

I may have a solution for you. I use under my Fedora 7 system and it permits me to close the xterm, yet leaving the pptpconfig front-end still running.

In my launcher, I added this command:

Code:
xterm -g 50x5 -title "Enter sudo password..." -e 'xhost + >& /dev/null; sudo /usr/bin/pptpconfig'
P.S. I setup my launcher to run as an "application" (not an "application in terminal").

Last edited by dwhitney67; 11-01-2007 at 01:42 AM.
 
Old 11-01-2007, 05:00 PM   #8
Casket
Member
 
Registered: Jul 2005
Location: Australia
Distribution: Slackware 10.1 - 2.4.29
Posts: 79

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by dwhitney67 View Post
Casket -

I may have a solution for you. I use under my Fedora 7 system and it permits me to close the xterm, yet leaving the pptpconfig front-end still running.

In my launcher, I added this command:

Code:
xterm -g 50x5 -title "Enter sudo password..." -e 'xhost + >& /dev/null; sudo /usr/bin/pptpconfig'
P.S. I setup my launcher to run as an "application" (not an "application in terminal").
Hi Dwhitney -

That worked However seeing as though my user doesn't need to enter a sudo password to run pptpconfig, is there a chance of modifying the command so it simply just launches?

Also I see your using /usr/bin/pptpconfig, I'm using /usr/sbin/pptpconfig - do you believe there are much differences here?
 
Old 11-02-2007, 06:05 AM   #9
dwhitney67
Senior Member
 
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,495

Rep: Reputation: 327Reputation: 327Reputation: 327Reputation: 327
Casket

Until today, I was not aware of the alternate pptpconfig in /usr/sbin.

When I attempted to use it (as a non-root user), it launched, but my stored VPN contact information (which I had created earlier as root using the alternate pptpconfig) was not displayed. When I attempted to create a new contact, the application gave me an error indicating that it failed to open /etc/pptpconfig/lock and thus it could not save the information. The permissions of the lock file do not permit non-root users to write.

Can you please confirm what the settings are on your system's lock file and for the two versions of the pptpconfig applications?

Code:
$ ls -l /etc/pptpconfig/lock /usr/bin/pptpconfig /usr/sbin/pptpconfig
-rw-rw-r-- 1 root root  0 2007-10-15 09:21 /etc/pptpconfig/lock
lrwxrwxrwx 1 root root 13 2007-10-14 22:26 /usr/bin/pptpconfig -> consolehelper
lrwxrwxrwx 1 root root 21 2007-10-14 22:26 /usr/sbin/pptpconfig -> ../bin/pptpconfig.php
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Launching files (test.txt) from a terminal window varankv Linux - Desktop 5 11-14-2007 01:17 AM
How to launch an app in terminal, & keep it running after I close terminal? kornerr Linux - General 7 06-24-2006 05:54 PM
Launching apps from the command line fieldyweb Linux - Newbie 5 01-14-2006 10:42 AM
launching programs from command line in FS dertien Linux - Software 1 11-26-2004 09:27 AM
Launching Programs From the Command Line Chryzmo Linux - Software 5 03-03-2004 08:00 PM


All times are GMT -5. The time now is 07:22 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration