LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 10-21-2009, 02:28 AM   #1
Watchin
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Rep: Reputation: 0
bash script start gedit but don't stop there


This command will stop until gedit is close...

gedit $file

How do you call gedit without it stopping?
 
Old 10-21-2009, 02:36 AM   #2
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by Watchin View Post
This command will stop until gedit is close...

gedit $file

How do you call gedit without it stopping?
Code:
$ gedit "$file" &
But this invocation of gedit will exit if you exit the shell that called it. To prevent that happening, do it this way:

Code:
$ nohup gedit "$file" > /dev/null 2>&1
This essentially cuts gedit off from the shell that launched it, e.g. makes it independent.
 
Old 10-21-2009, 09:52 PM   #3
Watchin
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks!

Thanks!

Last edited by Watchin; 10-21-2009 at 09:53 PM.
 
Old 10-24-2009, 04:22 AM   #4
Watchin
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Original Poster
Rep: Reputation: 0
Didn't work

Executing ./nt test opens the file test. But it still locks the terminal till gedit is closed.

Saved this as nt
Code:
#!/bin/bash
echo "input=$*"
nohup gedit "$*" > /dev/null 2>&1
This does the same.
alias gi='gedit > /dev/null 2>&1'
 
Old 10-24-2009, 06:55 AM   #5
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 100Reputation: 100
Quote:
Originally Posted by Watchin View Post
Executing ./nt test opens the file test. But it still locks the terminal till gedit is closed.

Saved this as nt
Code:
#!/bin/bash
echo "input=$*"
nohup gedit "$*" > /dev/null 2>&1
This does the same.
alias gi='gedit > /dev/null 2>&1'
Very sorry! In an earlier post I left off a critical symbol. It should be:

Code:
$ nohup gedit "$*" > /dev/null 2>&1 &
The final "&" causes the line to be spawned as a separate process, essentially disconnecting it from the parent. The only reliable way to close the spawned process is to kill it by its PID, or log out.

To capture the new process PID, do this:

Code:
$ nohup gedit "$*" > /dev/null 2>&1 &
$ mypid=$!
Then you can:

Code:
$ kill $mypid
Later on.
 
Old 10-29-2009, 02:24 AM   #6
Watchin
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by lutusp View Post
Very sorry! In an earlier post I left off a critical symbol. It should be:

Code:
$ nohup gedit "$*" > /dev/null 2>&1 &
The final "&" causes the line to be spawned as a separate process, essentially disconnecting it from the parent. The only reliable way to close the spawned process is to kill it by its PID, or log out.

To capture the new process PID, do this:

Code:
$ nohup gedit "$*" > /dev/null 2>&1 &
$ mypid=$!
Then you can:

Code:
$ kill $mypid
Later on.

Thanks for the update.

Now for the fun part, gedit .mybash, it opened without locking the terminal....


The nohup line doesn't work well in an alias, but this works:
  • alias ge='nt $*'

alias without the external would me more tidy, but I'm good.
 
Old 10-29-2009, 04:55 PM   #7
arizonagroovejet
Member
 
Registered: Jun 2005
Location: England
Distribution: SLED 11, openSUSE 11.4
Posts: 948

Rep: Reputation: 143Reputation: 143
The wording of the original post makes no sense to me, but given what's been posted since, I'm thinking maybe this will do what you want.
Code:
$ gedit filename & disown
E.g. you open gnome-terminal, type that, then close gnome-terminal and gedit stays running. If you were to omit the 'disown' part then gedit would close along with gnome-terminal.
 
1 members found this post helpful.
Old 10-30-2009, 01:39 AM   #8
Watchin
LQ Newbie
 
Registered: Jun 2009
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by arizonagroovejet View Post
The wording of the original post makes no sense to me, but given what's been posted since, I'm thinking maybe this will do what you want.
Code:
$ gedit filename & disown
E.g. you open gnome-terminal, type that, then close gnome-terminal and gedit stays running. If you were to omit the 'disown' part then gedit would close along with gnome-terminal.
My original post was a bit ambiguous, this would have been more clear
"This command will stop the terminal until gedit is closed..."

Sweet.
Thanks.
 
  


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
Start and stop script with screensaver esoukenka Fedora 3 11-08-2011 07:04 AM
Bash script stop CTRL+C stopping joshiggins Linux - Software 2 06-12-2008 04:45 AM
Start and stop a bash script based on network activity? creativetweak Linux - Software 8 05-04-2008 11:28 PM
using cron to start and stop a bash script monty Linux - Software 2 03-20-2006 03:30 PM
Bash script to alert by email 3 times then stop. pmpc00 Linux - General 2 11-04-2004 08:23 AM


All times are GMT -5. The time now is 06:53 AM.

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
Open Source Consulting | Domain Registration