2

Actually I mainly work with Ruby, but now I have created a bash script file. From this script file I am displaying the messages on the screen. Here is my scenario.

I have used aosd_cat module for displaying the messages on the screen and I did it successfully. For this I used their documentation .

Here is my message.sh script file:

#!/bin/bash
function message_1(){
  if [ condition ]
    echo 'message -1' | DISPLAY=:0 aosd_cat -u 10000 -e 2 -t 2 -R 'Green' -n 'Arial Bold 20' -p 0 -x 10 -y 60
  else
    echo 'message -4' | DISPLAY=:0 aosd_cat -u 10000 -e 2 -t 2 -R 'Green' -n 'Arial Bold 20' -p 0 -x 10 -y 60
  fi
}

function message_2(){
  echo 'message -2' | DISPLAY=:0 aosd_cat -u 10000 -e 2 -t 2 -R 'Green' -n 'Arial Bold 20' -p 0 -x 10 -y 60
}

function message_3(){
  echo 'message -3' | DISPLAY=:0 aosd_cat -u 10000 -e 2 -t 2 -R 'Green' -n 'Arial Bold 20' -p 0 -x 10 -y 60
}

# As I have to display messages continuously
while true
do
  message_1
  message_2
  message_3
done

After execution I get that messages are displaying one by one (message_1 is displaying first then message_2 and then message_3).

I have to display all the messages at the same time. To achieve this I think I can execute those commands in subshell/as subprocess/in the background (so it doesn't affect on other processes).

In ruby we have system command which executes the given command in a subshell. How can I achieve this type of functionality in the bash script file?

1 Answer 1

3

You can do it like this:

  bash -c command

but in your case perhaps sending the command to the background is enough:

  command &
1
  • as I am executing these commands continuously did they overwrite or replace each other during execution. Also I have edited my question please look into this
    – sk1712
    May 21, 2014 at 11:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .