1834882 Members
2264 Online
110071 Solutions
New Discussion

Re: loop or continue

 
SOLVED
Go to solution
eykyn17
Advisor

loop or continue

Guys,

I know this is so easy for you..
What is the command to get the result by 5seconds or if i press the enter key
exmple: I want to monitor the print queue every 5 seconds.
lpstat -a pintername

How do i do that instead typing the command again.

Apprecaite your help
8 REPLIES 8
David Bellamy
Respected Contributor
Solution

Re: loop or continue

while true
do
lpstat -a printername
sleep 5
done
this will loop until you do a Control -C
James R. Ferguson
Acclaimed Contributor

Re: loop or continue

Hi:

# while true; do
> lpstat -a printername
> sleep 5
> done

Using a Ctrl-C will interrupt (terminate) the loop.

Regards!

...JRF...
Pete Randall
Outstanding Contributor

Re: loop or continue

Write a little two line script:

lpstat -a printername
echo "full_path_of_myscript" |at now +5 minutes

The invoke that script with "echo "full_path_of_myscript" |at now +5 minutes"


Pete

Pete
Peter Nikitka
Honored Contributor

Re: loop or continue

Hi,

the triggy part is
>>
or if I press the enter key
<<

A solution - which is HP specific - is the command
line -t 5
(the -t option is only available under HP-UX):

while :
do
dummy=$(line -t 5)
lpstat -a printer
done

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
eykyn17
Advisor

Re: loop or continue

Hi ALL,

Thank you so much for the hint It really helps.

more power to all of you guys:-)
eykyn17
Advisor

Re: loop or continue

Hi ALL,

Thank you so much for all your reply. It really help me a lot it so much easier now.

more power to all of you guys:-)
hpuxrox
Respected Contributor

Re: loop or continue

while true
do
echo "Press Enter"
read
lpstat -a printer
done
eykyn17
Advisor

Re: loop or continue

thanks all