Operating System - HP-UX
1829739 Members
1618 Online
109992 Solutions
New Discussion

How to display a message for a few seconds only ?

 
SOLVED
Go to solution

How to display a message for a few seconds only ?

$ xterm -e "cat message ; sleep 30"
Can't execvp cat message ; sleep 30

$ /bin/sh -c xterm -e "cat message ; sleep 30"
Doesn't work

In the latter, I don't know how to nest quotes and group commands / arguments properly.

I don't know how to display an announcement message for a limited amount of time and then continue the main script.

Grrr...this simple and straightforward request has taken me already about 4 hours of frustration. I love VB, I like Tcl, but I have a love/hate relationship with...

Nobody seems to be able to tell me what "execvp" means and why it does what it does(n't do)...
10 REPLIES 10
harry d brown jr
Honored Contributor
Solution

Re: How to display a message for a few seconds only ?

/bin/sh -c 'xterm -e "echo HELLO WORLD;sleep 15"'

live free or die
harry
Live Free or Die
Muthukumar_5
Honored Contributor

Re: How to display a message for a few seconds only ?

xterm with -e can execute only one command. If you try to execute as,

xterm -e "cat message ; sleep 30"

xterm will try to run as,

execution of cat message ; sleep 30 can not be done.

Try as like as,

# cat > /tmp/test.ksh
cat message
sleep 30
# chmod +x /tmp/test.ksh
# export DISPLAY=ip:0
# xterm -e /tmp/test.ksh

It will do now
Easy to suggest when don't know about the problem!
Massimo Bianchi
Honored Contributor

Re: How to display a message for a few seconds only ?

Hi,

man execvp

will answer.

As to your problem, try with some parenthesis:
xterm -e /usr/local/myscript.sh

where myscript.sh is
#!/sbin/sh
/usr/bin/cat message
/usr/bin/sleep 30
exit 0


I tested it on my system and it works.

Regards,
Massimo




Massimo Bianchi
Honored Contributor

Re: How to display a message for a few seconds only ?

Hi,
just forgetting one thing: check that the DISPLAY variable is properly set :)

Regards,
Massimo
Franky_1
Respected Contributor

Re: How to display a message for a few seconds only ?

Hi Harald,

you can do the following :

create a script (executable file) with the following content

echo hello
sleep 5

then set the DISPLAY Variable and run the script

xterm -e /tmp/<script_name>

Regards

Franky
Don't worry be happy
Franky_1
Respected Contributor

Re: How to display a message for a few seconds only ?

Hi Harald,

did you try my solution ? It works ...

Regards

Franky
Don't worry be happy

Re: How to display a message for a few seconds only ?

Got it !

Thanks guys for pointing out that ";" and "xterm -e" are not friends.

"The solution to a problem changes the problem"
- What if I want my message to appear in "pager" and users don't have to wait for the 'sleep' period to complete...
harry d brown jr
Honored Contributor

Re: How to display a message for a few seconds only ?

for no wait:

/bin/sh -c 'xterm -e "echo message;sleep 15"' &

live free or die
harry
Live Free or Die
harry d brown jr
Honored Contributor

Re: How to display a message for a few seconds only ?

should have added an exit:

/bin/sh -c 'xterm -e "echo message;sleep 15;exit"' &

live free or die
harry
Live Free or Die
Gerard Leclercq
Trusted Contributor

Re: How to display a message for a few seconds only ?

There is a more elegant manner by using Xdialog (http://hpux.ee.ualberta.ca)

Example :

Xdialog --title "Message" --infoxbox "Write your message here" 0 0 30000&

Gerard