Aghhh! Keeping shell window open after menu launchForum: myDSL Extensions (deprecated) Topic: Aghhh! Keeping shell window open after menu launch started by: WoofyDugfock Posted by WoofyDugfock on Oct. 11 2004,13:04
How do you keep a window open after running an executable?Having conquered editing my fluxbox menus to add apps installed via synaptic, I thought it might be pleasant to be able to launch the command-line prog 'wipe' (say with the help info) from the right-click menu. This is a secure file deletion utility from apt-get and runs just dandy from a shell. Now I've tried a hundred things - all of them open a window for a picosecond before closing, presumably running wipe for that picosecond. For eg: [exec] (Wipe) {rxvt -rv -fn fixed -T "Wipe" -e /usr/bin/wipe -h} # this is in imitation of the bashburn line I've also tried calling Xterm instead which is supposed to have a -hold option to keep a window open after executing according to man - this don't work. But then dsl doesn't have he full version of this, does it? I've tried a lot of googling without success - too many dead-ends to remember. Agghhhhhhh!!!! Posted by mikshaw on Oct. 12 2004,02:42
I think the xterm in DSL is still rxvt, so xterm options which aren't available in rxvt probably won't work.Personally I just open a terminal and type the command if I want the term to remain open....it's really pretty easy =o) Posted by WoofyDugfock on Oct. 12 2004,05:37
Thanks for info about rxvt. Granted, just opening a shell and typing in a shell is easy enough. But I suppose it's become more the principle of the thing now! (I'm nothing if not stubborn).I mean, the bashburn line I quoted above does it for bashburn using rxvt, so it must be possible. But exactly the same syntax doesn't work for another command line executable! I noticed while I was googling that someone had had exactly the same question on a forum for some type of CLI nix implementation on MacOSX. There it had been solved two ways but the best was by running a simple sh script foo.sh from the line in the desktop menu prefs which opened a window and then executed whatever argument(s) followed the script using {*}. The window then wouldn't close until you did something in it. But I copied both methods and tried and they didn't work - either under sh or bash - but maybe different syntax. I've had trouble finding it again but I'll have another look. Any 'nix 'perts out there? Posted by WoofyDugfock on Oct. 12 2004,14:30
Well I've found a brute force solution of sorts mainly by very much trial and error however I doubt it's the best one. (Coders avert thy gaze).I wrote a little script opt/burble.sh which diplays the wipe help file and then calls the bash shell in an infinite (?) loop so the !@#^^&&** bastard can't close. Bend to my will or run forever .. So at least using the fluxbox menu to access wipe throws up the help file to read and keeps a shell open: #!/bin/sh /usr/bin/wipe -h while true do /bin/bash done In /home/dsl/.fluxbox/menu I then put: [exec] (Wipe) {sudo rxvt -rv -fn fixed -T "Wipe" -e /opt/./burble.sh} I thought you'd be horrified! You can't quit the shell by typing exit but the window can be closed by clicking the X. Of course, I wonder if the loop is still running underneath in which case it needs an improvement to shut that off!?? I tried experimenting with "wait" but to no avail. I gather that the actual problem is that wipe is running as a child of rxvt parent and the parent terminates when the child does, or something. However I don't know enough (anything) about process management in linux to fix this, 'fork()' and such. Takers? Posted by clacker on Oct. 12 2004,17:23
I'm more a giver than a taker.woofy, have you tried sleep? I find that sleep can be a useful thing sometimes. As in sleep 15 at the end of a script to keep the window open. An even better solution is to use a line like this: [exec] (Wipe) {rxvt -rv -T "Wipe" -e /bin/bash --init-file /opt/.../burble} and put your commands in the burble file. That uses burble as a start up script for bash. When that's done, you're in a bash shell. Do only that and you're OK, but I added the PS1 line to match the prompt to the default one. My burble would look like this: PS1='\u@\h:\w\$ ' /usr/bin/wipe -h Posted by WoofyDugfock on Oct. 13 2004,12:33
Thanks Clacker - I'll try these & read up on your PS1 line to work out how that works. I'll give sleep (as in the command) a go also.As for my burble.sh above, I worked out that a while loop is not needed at all (all it did was stop exit from working). Burble only needs two lines: #!/bin/bash /usr/bin/wipe -h /bin/bash/ I had an epiphany while I should have been sleeping: it works because burble.sh is the child process of parent rxvt & burble can't finish while the bash prompt it calls is waiting. While burble can't close neither can rxvt. So the window stays open. As you may have gathered I'm new to bash scripting (this is my first). DSL might turn me into a coder yet. Still puzzled as to why 'wait" wouldn't work. Oh well I suppose as I learn more scripting it will become clear. |