0

i want to open a new terminal and execute a script immediately to it (to set a title in the new tab) and i cannot configure this. I try:

gnome-terminal --tab-with-profile=$varname -x ./test.sh -c "script -a -c 'ping $varname' $PATH_REPORT/$varname.log"

Any help how can i execute the test.sh script which contains:

PROMPT_COMMAND='echo -ne "\033]0;${varname}\007"'

with the others in command i wrote?

  • PROMPT_COMMAND is only evaluated when a prompt is displayed. Since this is a non-interactive session, just do the echo -ne .... directly. – Stephen Harris Jul 13 '16 at 14:31
  • can you give me an example that it will run? ty (the exact command that you mean because i tried every possible way and the terminal did not opened). – user178591 Jul 13 '16 at 14:34
0

You can simplify your solution so that you only need to specify the hostname once. The test.sh script can set the prompt directly with the echo command and then run the ping you want.

$ cat test.sh
#!/bin/bash

echo -ne "\033]0;$1\007"
script -a -c "ping $1" $PATH_REPORT/$1.log

Now you can call this with

gnome-terminal -x ./test.sh $varname

(make sure PATH_REPORT is set in the script before hand,or exported from the current shell)

If you want more complicated executions then you can adjust the test.sh script as you need.

  • yeah now the problem is that i am going to open many shells i cannot: gnome-terminal \ --tab-with-profile=$var1 -e "./test.sh" $var1 \ --tab-with-profile=$var2 -e "./test.sh" $var2 – user178591 Jul 13 '16 at 15:16
  • With -e you need to specify -e "$PWD/test.sh $var1". I assume you have the profiles all set up! – Stephen Harris Jul 13 '16 at 15:26
  • If you don't need specific profiles then you can just use --tab; eg gnome-terminal --tab -e "$PWD/test.sh $var1" --tab -e "$PWD/test.sh $var2" – Stephen Harris Jul 13 '16 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy