View previous topic :: View next topic |
Author |
Message |
roytheman Tux's lil' helper
Joined: 08 Nov 2009 Posts: 102
|
Posted: Wed Sep 25, 2013 2:02 pm Post subject: [SOLVED] Simple Bash Script Needed for VDR and Konsole |
|
|
Hello Gentoo forum,
Would somebody be so kind to submit for me a bash script to add to the script I already have pasted below? The script below works fine but the terminal window (konsole) remains open when I close the main program (VDR) and I would love for the script to automatically close the terminal window when I close VDR.
The purpose of this script is to enable me to view the log messages on the fly via a terminal window when VDR is opened but the terminal window remains open after I shut down VDR and I would like VDR to close the terminal when VDR shuts down.
I keep the script on my desktop (non-root) for a quick and convenient way to start VDR.
I know very little about how to write bash scripts but find them very interesting.
Sincerely,
Roy
Code: |
#!/bin/bash
/usr/bin/vdr -l 3 --lirc -P "*" &
/usr/bin/konsole -e tail -f /var/log/syslog
|
Last edited by roytheman on Wed Sep 25, 2013 8:28 pm; edited 1 time in total |
|
Back to top |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6747
|
Posted: Wed Sep 25, 2013 3:58 pm Post subject: Re: Simple Bash Script Needed for VDR and Konsole |
|
|
Untested, but if it does not work, it should give you the idea how to fix it.
BTW, since your script doesn't use bashisms, you can make it "#!/bin/sh" or - even more compatible - #!/usr/bin/env sh. Also, there is no need for your commands to specify the path.
Code: | #!/usr/bin/env sh
vdr -l 3 --lirc -P "*" &
vdr_id=${!}
konsole -e tail -f /var/log/syslog &
konsole_id=${!}
wait "${vdr_id}"
kill -TERM "${konsole_id}" |
Perhaps instead of TERM another signal is needed (like QUIT, INT, or HUP. KILL certainly works, but you should use this only as the last resort). Perhaps you also have to make the konsole subprocess aware of the signal and die when you receive the signal.
BTW, are you sure that /var/log/syslog is world-readable? I am not sure whether this is a good idea concerning security. |
|
Back to top |
|
|
roytheman Tux's lil' helper
Joined: 08 Nov 2009 Posts: 102
|
Posted: Wed Sep 25, 2013 8:25 pm Post subject: |
|
|
Hello mv,
I got the script to working by using the "--nofork" option, to make the terminal run in the foreground instead of the backgound, as shown below:
Code: |
/usr/bin/vdr -l 3 --lirc -P "*" &
vdr_id=${!}
/usr/bin/konsole --nofork -e tail -f /var/log/syslog &
konsole_id=${!}
wait "${vdr_id}"
kill -TERM "${konsole_id}"
|
Now the terminal closes after I close VDR.
I could not have done it without your help, so thank you very much.
Roy |
|
Back to top |
|
|
roytheman Tux's lil' helper
Joined: 08 Nov 2009 Posts: 102
|
Posted: Thu Sep 26, 2013 3:58 pm Post subject: |
|
|
Code: |
BTW, are you sure that /var/log/syslog is world-readable? I am not sure whether this is a good idea concerning security.
|
The syslog file is owned by root. Perhaps the reason it can be accessed as non-root when using VDR is because VDR owns several directories since VDR has been added as a user. Other than that, I don't know why.
Roy |
|
Back to top |
|
|
|