Help with bash script to open arbitrary # of independent xterms


View Poll Results: How Difficult is this solution on a 1(low) to 5(High) scale
rated 1 or 2 if low difficulty 0 0%
rated 3 if middle difficulty 0 0%
rated 4 if somewhat difficult 0 0%
rated 5 if way too difficult bordering on impossible to do 0 0%
Multiple Choice Poll. Voters: 0. This poll is closed

 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with bash script to open arbitrary # of independent xterms
# 1  
Old 09-04-2014
Help with bash script to open arbitrary # of independent xterms

I run multiple processes that require I pop open multiple xterms, how can I do this in a script and have each xterm colored differently and labled for the servername they represent, for example if I do ssh username@serverip I would need the xterm to be opened with that servername at the top and have it colored differently than the next xterm, the max # of terms I need for now is 6, but sometimes its 3 or 4, 5. Can anyone help with this.Smilie
# 2  
Old 09-04-2014
Window titles and console colors are handled inside the xterms, not outside. There is a special escape sequence to set the window title for instance, which your servers might be using already for all I know.

For instance, my profile has PROMPT_COMMAND set to
Code:
echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"

...which sets the window title to username@host:/path/to/currentfolder every time it prints a prompt.

It also has PS1 set to
Code:
\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\]

...which causes it to print colored prompts like

Code:
username@host ~/path/to/folder $command

This is specific to the BASH shells. If you're using other shells it may be configured differently.

Last edited by Corona688; 09-04-2014 at 04:16 PM..
# 3  
Old 09-04-2014
To force different values for these variables on login, perhaps something like:

Code:
ssh username@serverip 'PS1="# " ; export PS1 ; PROMPT_COMMAND="" ; export PROMPT_COMMAND ; exec bash --norc --nologin'

# 4  
Old 09-05-2014
Before anything else: PLEASE REMOVE the poll - it is completely unnecessary, doesn't help anyone and the only thing it does is making you look clueless and desperate.

Second, and this might answer your poll question: have a look at the man page of xterm and you will find the "-fg" option for the foreground colour, the "-bg" option for the background colour, the "-fn" option for the font, the "-cr" option for the cursor colour, and some more. You can also put defaults for these (and more) values into the repective rc-files of your windowmanager, you can use arbitrary X-resource-strings with the "-xrm" option and a lot things more.

Is it easy or difficult to consult a man page? Ask yourself.

I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

TCL script to extract the file name and then create two independent list

I am having one problem as stated below Problem Description I am having some "sv" extension files , I am using "glob" to extract the matching files , Now in these matching files , I need to split them and extract the elements and create different lists. For example set files This... (1 Reply)
Discussion started by: kshitij
1 Replies

2. Shell Programming and Scripting

TCL script to capture range of lines and create two independent variables

Hi I am having a code as stated below module abcd( a , b , c ,da , fa, na , ta , ma , ra , ta, la , pa ); input a , b, da ,fa , na , ta , ma; output c , ra ,ta , la ,pa ; wire a , b , da , fa ,na , ta , ma; // MBIST Structures... (1 Reply)
Discussion started by: kshitij
1 Replies

3. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

4. UNIX for Advanced & Expert Users

Pass Multiple Commands and Open Multiple Xterms via PSS

Hello, I'm attempting to open multiple xterms and run a command as an SAP user via sudo using PSSH. So far, I'm able to run PSSH to a file of servers with no check for keys, open every xterm in to the servers in the file list, and SUDO to the SAP(ADM) user, but it won't do anything else... (11 Replies)
Discussion started by: icemanj
11 Replies

5. Shell Programming and Scripting

Bash script reg-exp , replace , open and write

Hi All I am a new in scripting language and I would like help for you guys I would like to create a file named constant.h and search into all files *.m in specific directory for a reg-exp @"LBL_]+" exp: @"LBL_75847" , and write those matchs to constant.h if there are not written (no... (15 Replies)
Discussion started by: molwiko
15 Replies

6. Shell Programming and Scripting

Arbitrary permutation and combination script

#!/bin/bash # permutation_combination.sh # Version: 2.0 # Author : YongYe <complex.invoke@gmail.com> arg0=-1 argv=${3} number=${2} eval ary=({1..${1}}) length=${#ary} percom(){ nsloop i ${1} number${2} ${3} ${4} ${5}; } invoke(){ echo $(percom ${argu} nsloop -1) prtcom $(percom... (1 Reply)
Discussion started by: complex.invoke
1 Replies

7. Programming

Creating a bash script that create/open database

Hi. I have two text files(tables) which include some information and I want to make some query codes using them. First of all, I want to create bash script that read this two tables, create/open database and insert data from files into database. #!/bin/bash while read line; do ... (1 Reply)
Discussion started by: rlaxodus
1 Replies

8. Shell Programming and Scripting

Commands to multiple xterms

Hi, I need some help with sending commands to multiple xterms. What I do is ssh -Y to a remote box, and then open up 4 shells (csh) and on each one I run a different program in sequence -- one of them has 2, the first of which goes into the background and after you hit "enter" or "return" you get... (0 Replies)
Discussion started by: rmoriarty
0 Replies

9. Shell Programming and Scripting

Open and work on a .doc file with bash script

Hello there....unix users :) I hope you can help me with this: I need open a doc file or xls files and work this files whit a bash script. For example: Open a doc file and copy information from a txt file in this doc file or xls file. Is it possible? Sorry for my english...I'm chilean... (3 Replies)
Discussion started by: bobbasystem
3 Replies

10. UNIX Desktop Questions & Answers

resize multiple xclients (xterms) on command line or programmatically?

Is there a way to resize x clients after they're started either on the command line or programmatically? I'm using Cygwin and typically start my root window, wm, and four xterms. By the end of the day they're all over the place with different sizes. I'd like to be able to enter a single command... (0 Replies)
Discussion started by: gctaylor
0 Replies
Login or Register to Ask a Question