My two most often-used commands are top and ps -ejH. I decided to make a couple of panel launchers for them, with homemade .png icons which read (wait for it) 'top' and 'ps'.
'top' works fine. Click on the icon, and xfce4-terminal opens with top running.
'ps' doesn't. Click on the icon and a terminal window appears and vanishes. I've tried a whole range of possibilities, including specifying various commands for the launcher beginning with 'xfce4-terminal'.
What works is this command: xterm -hold -e ps -ejH. Good old xterm opens, executes ps -ejH and stays open.
There doesn't seem to be a '-hold' option for xfce4-terminal. Any other way I can keep it open with a single command?
Check the man page for exo-open. It might be what you're looking for.
Maybe I wasn't clear enough about the problem!
I can launch xfce4-terminal with a panel launcher with any one of a whole range of command options. The problem is that xfce4-terminal closes down after executing ps -ejH in a fraction of a second (I can see it flash by). I can't get it to stay open. This is easy to do with the '-hold' option in xterm, so I'm hoping there's some little-known or clever command option for xfce4-terminal that does this as well.
Does exo-open get around the problem or is it the same deal?
Alternative solution might be to pipe ps' output into a pager like less.
No, exo-open just launches xfce4-terminal to execute ps -ejH, but it doesn't keep xfce4-terminal open. Same with piping the ps -ejH output to various commands.
However (Ta da!) this almost works (and it won't work with -e instead of -x):
xfce4-terminal -H -x ps -ejH
Problem is, the command doesn't complete and return me to the prompt. I get to see the process tree, but I can't act on it (e.g., kill a process). I have to close the terminal and re-open it.
What can I add to the command to finish ps -ejH and get a prompt? (Yes, I know I could do a script here, but it would be neat to do it just with terminal commands...)
Edit: I actually don't have to close the terminal, I can open a new tab and enter commands there, but it would still be good to do it in the ps tab.
Try this as paramters for your xfce4-terminal: "ps -ejH && /bin/csh"
Replace csh with your shell path. Keep the quotation marks.
Thanks for the interesting idea, but with xfce4-terminal -e "ps -ejH && /bin/bash", the terminal appears but doesn't stay open.
Could you open a Terminal or Xterm, etc. and try that command from there. Maybe it's returning some error.
In xfce4-terminal, entering ps -ejH && /bin/bash executes ps -ejH and brings me back to a prompt.
If I launch xfce4-terminal with a panel launcher, either the plain command
xfce4-terminal -e "ps -ejH && /bin/bash"
ps -ejH && /bin/bash
with 'Run in terminal' checked gives me the 'now you see it, now you don't' flash-past.
[Logging off, maybe more tomorrow, many thanks]
How about just running Conky and always have it visible some where on the desktop? Sounds like a cleaner solution to what you'd like
Yes, conky is cleaner and prettier - if you have lots of screen real estate. I have a 13" laptop display running at 1280x800 px.
Normally I just do Ctrl+Alt+t (custom keyboard shortcut) to call up xfce4-terminal, then type in commands, and I still do that for most CLI jobs. As a newcomer to Xfce I thought I'd see how far I could push panel launching!
Anyway, xfce4-terminal -H -x ps -ejH does the job. Many thanks.
Hey, I had a similar problem, while trying to login to the terminal. If you run su in the terminal as you open the terminal, then you should have your problem solved. It worked for me, and I hope it helps.
I don't think my reflexes are good enough to enter su in the terminal as it launches. It's only open for a fraction of a second!
lol. I must apologize. What I meant was for you to run su in terminal before you open. All you have to do is right-click the terminal icon in your system tray or go to your program launcher. There is a setting you can change to always run the command su in the terminal as it opens. Again, sorry for the lack of detail or clearity. Hope that helps.
Interesting idea. Are you saying I should just su to myself before running the command? (Otherwise I'd be switching to root, which requires a password, which defeats the purpose of a launcher that opens a terminal with the command running.)
I can't see how that would get around the problem, and when I try coupling the commands (and using the Run in terminal option), I get the usual flash-past of a terminal opening and closing in the blink of an eye. Can you suggest a syntax?
P.S. Have you read Richard Stallman's entertaining entry in info su?
Sorry, that it wouldn't work. It worked for me to just run su command in the terminal before I opened the window. Maybe the distribution you are using requires a different command, such as sudo. I am running FreeBSD. Sorry if I am wasting time here.
No, no! Not wasting time! This forum is all about trying different things to see if they work. Many thanks for your suggestion, it was definitely worth trying. (And sudo also doesn't work...)
I have no idea if su can work, but you could try it with the -m option followed by your user, and the -c option for the command. Check your su man page in case your system has different options.
man su says "If the target user has a restricted shell, this option has no effect" for the -m and -p options. No effect: terminal opens and closes.
I'm still trying to get my head around being logged in, then su'ing to myself...
Deja vu all over again. It looks like exactly this issue was raised and discussed 3 years ago on Ubuntu forums:
No fix there, either. It's curious that I can get the command to complete (i.e., and return me to the prompt) with xfce4-terminal "pre-opened", but not when I launch it with that same command.
Why not use bash magic?
#!/bin/bash ps -ejH echo "Press any key to close!" read
No reason why I couldn't, but like I said in an earlier post on this thread, "Yes, I know I could do a script here, but it would be neat to do it just with terminal commands...". It's a tinkering instinct. At the moment my only script-by-panel-launch is an rsync. And for ps purposes I'm happy enough with xfce4-terminal -H -x ps -ejH, even though it doesn't complete.
Executing commands while switching users should be possible. The only restriction I know of, is when switching to UID 0, which requires that your user be a member of the administrative group (e.g. wheel). I think su itself is working in your case, but it's just doing the same thing as the other commands that you've tried so far and have failed.
But I guess switching to your own user is quite weird, yes.
Why don't you use Xterm (with -hold) just for that command alone?
This thread's getting so long it's easy to forget previous posts! In my 2nd one I said "I can't get it to stay open. This is easy to do with the '-hold' option in xterm, so I'm hoping there's some little-known or clever command option for xfce4-terminal that does this as well."
I actually like good old xterm, and would use it as default terminal except it doesn't have tabs.
Just to clarify my previous post. I misunderstood the situation. Late night caused my own confusion. Sorry for any confusion. Su didn't work for me in your case. Another issue I had problems with long ago.