View previous topic :: View next topic |
Author |
Message |
nordic bro Guru
Joined: 25 Oct 2003 Posts: 585
|
Posted: Tue Aug 20, 2013 5:35 pm Post subject: shell exec cmd prob [solved] |
|
|
this is run from a script that's started by a desktop file to pop up a terminal to temporarily interact with. I need to:
1. prevent terminal from closing immediately after input since I may have entered it wrong and need to re-enter;
2. use the open terminal to temporarily block subsequent things in the script from running until I'm ready to have them run.
/usr/bin/xterm -e sh -c "echo -n pw | sudo openconnect .... --background ...; sh"
I'm using 2-factor auth so openconnect will display a "Response:" prompt - if I mistype the code openconnect will ask for pw again then "Response:" once more so added "; sh" to keep terminal open temporarily.
then once I'm on the vpn I have to do a second administrator-like login on the vpn via my web browser which I don't think the script can be used to monitor so instead I use the fact the open terminal will temporarily block the rest of the script until this second login is complete. I then close the terminal with the intention of allowing the script to continue its other tasks.
part 1 works fine, the problem is part 2 in that when I close the terminal it kills the vpn session. is what I'm using now too convoluted and/or will never work? or maybe there's a fix for #2? I've tried "&" here and there to background openconnect (although it has its own "--background" so wouldn't think that's needed) such that it doesn't get killed but so far anywhere I put it doesn't have the desired effect - maybe some embedded shell subtlety I'm not appreciating?
thanks.
Last edited by nordic bro on Tue Aug 27, 2013 12:23 am; edited 1 time in total |
|
Back to top |
|
|
tomk Bodhisattva
Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Wed Aug 21, 2013 7:41 pm Post subject: |
|
|
Moved from Portage & Programming to Desktop Environments at nordic bro's request. _________________ Search | Read | Answer | Report | Strip |
|
Back to top |
|
|
nordic bro Guru
Joined: 25 Oct 2003 Posts: 585
|
Posted: Tue Aug 27, 2013 12:22 am Post subject: |
|
|
turns out an openconnect option was causing the problem ("--setuid" which is to drop to user privs after vpn is up). I tried many experiments including nohup/disown, other terminals/shells, etc., but not until I removed that option did the session stay up after terminal was closed. I can use that option if I copy/paste the cmd into an existing xterm then close after, must be a combo thing of how I'm having the script pop up an xterm that leads to the trouble. |
|
Back to top |
|
|
mv Watchman
Joined: 20 Apr 2005 Posts: 6780
|
Posted: Wed Aug 28, 2013 10:05 pm Post subject: |
|
|
If a program opens a file (here probably a tty) then it still can access the file even after privileges are dropped. However, once it closes the file and reopens, it needs the appropriate privileges. This is the same problem why "screen" is in certain situations unable to attach to the active terminal. |
|
Back to top |
|
|
|