Find the answer to your Linux question:
Results 1 to 4 of 4
Hi there, I'm looking to open two xterm windows and have them both tail -f a couple of log files. so my question is: How do you do this? Also, ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    2

    Opening two xterm windows through a script

    Hi there,
    I'm looking to open two xterm windows and have them both tail -f a couple of log files. so my question is: How do you do this? Also, is there a way I can make the two new xterm windows independent from the original xterm window that I launch the script in, in other words, I'd like to be able to close the original xterm window without the two new windows closing.

    Can this be done?

    Thanks in advance.

  2. #2
    Linux Engineer
    Join Date
    Nov 2004
    Location
    Ft. Polk, LA
    Posts
    796
    You can specify what program to run when you start xterm with the -e option. See the xterm man page for more info. As far as closing xterm but keeping the other things open, I forget how to do that. For some reason I think it's actually a shell option, but don't quote me on that. I didn't see anything about it by skimming through xterm or bash man page, but I could have missed it.

  3. #3
    Just Joined!
    Join Date
    Oct 2007
    Posts
    2
    okay, thanks, I have found the command that I need and it works perfectly when executing it directly from the command prompt, but it doesn't work when run from a simple script file..

    The comamnd I'm using is..

    xterm -e tail -f data/dev.log &

    the second log is opened with:

    xterm -e tail -f data/op.log &


    BTW, the & is what makes the new window independant of the original window...

    So, that works from the command prompt, but putting the two commands in a file like this:

    xterm -e tail -f data/dev.log &
    xterm -e tail -f data/op.log &

    then just CHMOD'ing the file 775 and running it opens and closes the windows. i'm left with nothing except the first xterm window where I executed the script from.

    What's happening here? How can i keep both of the windows open and alive?

    Thanks!

  4. #4
    Linux Guru gogalthorp's Avatar
    Join Date
    Oct 2006
    Location
    West (by God) Virginia
    Posts
    3,105
    Start the script with the & option instead of the embedded commands. ie run the script as a new process (thread) not new processes for each command.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...