keeping xterm open?
hello,
I have a commandline based program which I run in an xterm, called from a fluxbox menu (so I dont manually open the xterm myself). Code:
xterm -e program Is there a way to keep an xterm open so that a program can run multiple commandlines in that one xterm instance? like this: Code:
1. call xterm |
Is this a bash script or what? What is this "program" supposed to do and how? It would be nice if we could see the source.
|
Hello Alan,
The program is 'rkhunter'. http://rkhunter.sourceforge.net/ It is a program for detecting rootkits, and run's in console or terminal. I would like to run it in an Xterm. There two commands I need to run together: Code:
rkhunter --update Code:
rkhunter -c I would like to run these two commands in the same instance of Xterm. the problem is that I call xterm from another program (fluxbox menu), and it opens xterm and executes the first of the commands, but then once that has finished, the Xterm closes, so I am unable to run the second command (in the same Xterm window). |
Hello Bergman :)
I've been looking for a way to do what you want to do for some time; it may not be possible (why not? IIRC it was possible on HP-UX and Solaris). You could write a script to do steps 2 and 3 and leave the terminal open while the user reads the output. The reader would unfortunatel not then ba able to do anything except close the terminal. You could call the script from the fluxbox menu with xterm -e myscript The script could be something like (not tested -- just to give the idea) Code:
#! /bin/bash Charles |
This is just a quick answer since I don't use xterm,rkhunter and Fluxbox but you can see if it works.Why don't you make "one command" out of this two that you now have;
Code:
rkhunter --update && rkhunter -c |
Quote:
I didnt think of passing a script to xterm :) Code:
xterm -e rkhunter --update && rkhunter -c it runs 'rkhunter --update' in an xterm, but when the update has finished, xterm closes. I think that the 'rkhunter -c' part is being executed because my cpu is at 100%, but its in the background and Im unable to view it. |
You could put your rkhunter commands in a rc file,
Code:
cat > ~/.rkhunter.bashrc <<_EOF Code:
xterm -e "/usr/bin/bash --rcfile ~/.rkhunter.bashrc" Don't forget to source your existing ~/.bashrc into your rkhunter.bashrc file if you have one as the --rcfile option will mean it won't get run otherwise. |
Actually,what I had in mind was something like;
Code:
xterm -e "bash /path/to_the/script" |
thanks :)
I didnt consider the possibility that I may need the prompt back at some point. Could you explain what this part of the script does? I notice that when I look into the script after creation, this part is missing? Code:
cat > ~/.rkhunter.bashrc <<_EOF |
Quote:
Code:
xterm -e "/path/to_the/script" Code:
The final example is very similar to what happens with my --rcfile suggestion, except the shell you get dumped into on completion won't be the same one that your commands ran in. It'll be a sub process. |
Quote:
It's called a 'Here Document' Basically, what it's saying is: run cat redirecting the output (>) to ~/.rkhunter.bashrc taking the input from the following lines until you find the characters _EOF (<<_EOF) If you look at man bash and search for "Here Documents" it'll explain it all in gory detail. They're a very useful tool at times. |
oh I see.
Thanks again, Ive learned some interesting things from this thread :) |
Quote:
I've been looking for a way to achieve that functionality for ages (and not understanding why the graphical terminal programs don't facilitate it). Adapting your technique for GNOME on ubuntu 8 only required changing xterm to gnome-terminal and /usr/bin/bash to /bin/bash. Sweet! Best Charles |
Quote:
Code:
xterm -e " command1 ; command2 ; bash" Code:
xterm -e "bash /path/to_the/script" ...and yes, Code:
xterm -e "/path/to_the/script" Code:
xterm -e "bash /path/to_the/script" |
Quote:
In the second you're passing 1 command to xterm which is bash and providing bash with an input script file to run. When bash gets to the end-of-file in that input file it will exit, which in turn will cause the xterm to exit. That doesn't happen in the first example as the final bash doesn't receive and end-of-file. In the context of what the original poster was trying to achieve (i.e. open a xterm and run some commands in it but leave it open) the difference is clear. one will exit on completion and the other remains open. Having said that, it's still a bit of a hack, and using the --rcfile parameter could probably be considered more correct. |
All times are GMT -5. The time now is 10:06 AM. |