How to refresh a graphical display through bash script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to refresh a graphical display through bash script
# 1  
Old 07-25-2011
How to refresh a graphical display through bash script

Hi folks ,

I need to display a message graphically using a messagebox or textbox through bash script. However the message should be keep changing every 4 secs . I input the message from a file and use "gxmessage" to display it .

Code:
gxmessage -nofocus -center -title "Welcome screen" -geometry "600,600" -wrap -file $random

Where "$random" is some random data from a file.
But the problem is , how should I refresh the same gxmessage message box,putting different message each time .

I thought of

Code:
while :
do
        sleep 4
        if ps | grep "gxmessage"
        then
                killall -9 "gxmessage"
        fi
        gxmessage -nofocus -center -title "Welcome screen" -geometry "600,600" -wrap -file $random &
 done &

I hate this solution and it looks ugly too , because it is visible that the message box is getting killed and forked every time .

Can't I use the same gxmessage message box for all the messages just by putting new messages and hence refreshing the same box.
Any idea , anything other than gxmessage will do , if a solution is somewhere else.

And I am a newbie Smilie

Thanks.
D.
# 2  
Old 07-25-2011
# 3  
Old 07-26-2011
If you're not dead set on using gxmessage, you could start an xterm and execute a small script which pulls random data from a file. Here's a sample that computes a random line to pull from a cookie file and displays it for a few seconds before pulling and displaying the next. If you're willing to write the script given to xterm as a standalone, then the xterm command is less of a mess.

Code:
xterm +sb -T "window title" -geometry 132x24+100+100 -foreground yellow -background blue -e 'w=10 
cookie_file=~/lib/biscuits   # one biscuit (or American cookie) per line
n=30    # number of lines in ibiscuits
while (( $w > 0 ))
do
    r=$(( ($RANDOM % $n) + 1))
    cookie=$( head -$r $cookie_file | tail -1)
    print "\0033[H$(date)  $r $cookie\0033[K"  # home cursor, write cookie, clear to end of line
    sleep 5
    w=$(( w - 1 ))
done'

This User Gave Thanks to agama For This Post:
# 4  
Old 07-27-2011
Thanks all.
@agama : I did this using xterm and found that really useful related to my requirement , for refreshing , I just cleared the screen every 2 seconds .

Code:
xterm -geometry 20x3+1300+0 -ms "green"  -fs +80 -T "STAT" -w 4  -bg "black" -fg "Gold" -e ./cpuscript.sh &

Where the script called is an infinte loop to hold,display,and clear the screen.

Code:
#!/bin/bash
############# SCRIPT CALLED BY XTERM TO DISPLAU CPU AND MEMORY USAGE ######################
while :
do
        clear
        echo "CPU: $(cat $cpustat | tail -1) %" #File to get dynamic CPU usage , have done it using ps in another script
        echo "MEM: $(cat $memstat | tail -1) %" #File to get dynamic Mem usage , have done it using ps in another script
        sleep 2
done

exit 0

Thanks once again.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Graphical Display Of Script Execution & Output

Hello All i have a KSH script which basically takes attribute name as input argument and searches whole Netezza appliance and prints information of where that column is used (Table/Views) etc. Problem with this approach business users have to raise SUDO access request, Install Putty, run through... (1 Reply)
Discussion started by: Ariean
1 Replies

2. Shell Programming and Scripting

Refresh web page in bash script

hello, I am trying to refresh my web page which is created in bash script. I have a HTML page which when press a button calls a bash script. this bash script created the same page with dynamic data. When pressing the button I am calling to a function that set time out of 7 seconds and and after... (1 Reply)
Discussion started by: SH78
1 Replies

3. Red Hat

Cannot show graphical login display

Hi all, I'm running Red Hat Enterprise Linux Server 6.3 Santiago. I already installed the X Window package during installation and the graphical login display can be shown normally after installation. Yesterday, I accessed remotely by GUI mode using VNC viewer and somehow it got crashed.... (1 Reply)
Discussion started by: sergionicosta
1 Replies

4. Shell Programming and Scripting

Bash script to display result in table

My script gives the following result. Is it possible to display the same in table format ? 1. rex_best Latest feeds are not avaialable. The last feed was generated on 2012-05-17 File Name = ekb_best_20120517_010949_665.tar.gz The Number of entry elements = 4209539 2. rex_genre Latest... (2 Replies)
Discussion started by: kishorekumar87
2 Replies

5. Shell Programming and Scripting

bash script to display tail

Hi everyone, I'm trying to write a script to format a file using unix2dos. I want to output all but the first 14 lines in a file. Then I want to pipe this to unix2dos to convert the output to a file that's easily readable on windows. Here's what I have: export Lines=`wc -l < $1` export... (11 Replies)
Discussion started by: LuminalZero
11 Replies

6. UNIX and Linux Applications

invoke remote graphical application..and display locally

Hi, I want to invoke(run) a graphical application remotely, and the display should be in remote itself. (no X redirect).i want to do this through ssh. like if i login to a remote machine and run firefox it should display there itself. how can i do this..? (2 Replies)
Discussion started by: madhusudankh
2 Replies

7. HP-UX

need graphical display of Hp server

Hi all, i need graphical display of my Hp server to install oracle software.i connected it through telnet.can we connect from windows client to Hp server through remote desktop connection.please guide.i try a lot to get it. thanks in advance. (1 Reply)
Discussion started by: younusdba
1 Replies

8. Shell Programming and Scripting

Display runnning countdown in a bash script?

I am looking for a way to display on a single line, a running countdown for a given amount of time in a terminal using a bash script. I am looking for this to use as part of a larger bash script that captures Video. The script sets up a bunch of parameters for DVgrab, and one of the parameters... (11 Replies)
Discussion started by: Starcast
11 Replies

9. UNIX for Dummies Questions & Answers

Refresh ls list on screen (auto-refresh)?

I am looking for a way to issue a command or string of commands to repeatedly display new files that are written to the directory. I usually use ls -ltr to see the newest files at the bottom of the screen. I would like to automate this command to refresh what is displayed every second or so. Can... (3 Replies)
Discussion started by: skidude
3 Replies
Login or Register to Ask a Question