Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
-e program [ arguments ... ]
This option specifies the program (and its command line argu-
ments) to be run in the xterm window. It also sets the window
title and icon name to be the basename of the program being
executed if neither -T nor -n are given on the command line.
This must be the last option on the command line.
I fond this email posting while searching solutions to the problem I have while tring to execute commands in new xterms from script. I my script I wrote:
xterm -e ls &
xterm -e date &
xterm -e pwd &
When I run the script, it opened up three terminals but they fade away, I'm not sure whether they has excuted commands. Any idea?
The problem is that the commands that you are running end. When the command ends, the window closes. If you want to run this type of command and keep the window open, you can force a bash prompt. For example:
xterm -e ls\;bash &
The ';' separates commands, so the above issues two commands: 'ls' and 'bash'. The ';' has a backslash in front of it, because we want to send the ';' to xterm, not use it to end the xterm command.
Thanks a lot, I've tried it and it worked with xterm. I have changed my script to use gnome-terminal instead of xterm, somehow bash command won't work with gnome-terminal, I wonder why?
Thanks a lot!
Gnome-terminal works differently from xterm. The easiest way to do this with gnome-terminal is, for example:
gnome-terminal -e "bash -c ls\;bash"
This says to run gnome-terminal and pass it the command "bash". The bash command will be passed the option "-c" which causes it ro run the commands "ls" followed by bash as in the earlier xterm example.