LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 05-02-2016, 05:10 PM   #16
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169

Quote:
Originally Posted by Habitual View Post
console vs terminal emulator.

Stopping a script from either is trivial.
The use of correct terminology/nomenclature shouldn't be.
Drinking water is trivial.

Stopping a script running in a console AND closing that console is not.

So far, my method is the only one that has worked.
 
Old 05-03-2016, 07:03 AM   #17
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Closing a session in either a console or a terminal really is trivial. urxvt is a terminal (short for terminal emulator). I have urxvt here and can't figure out any combination yet that prevents me from closing the terminal window using the advice I gave above and repeat here:

Code:
./some/script && exit
Something about your arrangement is more complex or different than is coming through in the posts. How, specifically, are you launching your script?
 
Old 05-03-2016, 09:36 AM   #18
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
I open a urxvt console and then run this.

Code:
#!/bin/bash 
#
#     Help from "Grasshopper" :-)
#
# Convert mp4 to mp3
#

for vid in *.mp4; do ffmpeg -i "$vid" "${vid%.mp4}.mp3"; done
rm *.mp4
gxmessage -timeout 2 "Conversion from mp4 to mp3 complete !!"
kill $(pgrep urxvt)
 
Old 05-03-2016, 12:45 PM   #19
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Oh. If you are trying to kill the parent process, the you can point "kill" at the environment variable $PPID. That variable gets automatically filled in with the process id of the parent process. In the case of your script, that would be the shell which has called it. And then the terminal will go away after the shell hangs up. So try it this way:

Code:
#!/bin/bash 
#
#     Help from "Grasshopper" :-)
#
# Convert mp4 to mp3
# 

for vid in *.mp4; do ffmpeg -i "$vid" "${vid%.mp4}.mp3"; done
rm *.mp4
gxmessage -timeout 2 "Conversion from mp4 to mp3 complete !!"
kill -s HUP $PPID
HUP is the hangup signal and -s tells "kill" to send the hangup signal to the parent process id as specified by $PPID. You can read more about signals in the manual page: man 7 signal.


But if you are running the script ./this, then you can tell it to quit "urxvt" with exit.

Code:
./this && exit

Last edited by Turbocapitalist; 05-03-2016 at 12:46 PM.
 
Old 05-03-2016, 03:36 PM   #20
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Thanks a lot and it does not close other open console windows.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] closing parenthesis script cruzdelsur Programming 5 08-30-2010 09:55 AM
Closing a virtual console Akky Linux - General 7 08-13-2009 07:41 AM
auto closing console ? Bob Armstrong Linux - Newbie 7 08-04-2008 01:36 PM
nvidia problem: console unreadable after closing X drkstr Linux - Software 6 04-04-2006 01:34 PM
Closing programs with console john7343 Linux - Software 3 02-22-2006 05:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:27 PM.

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