[SunHELP] Scripting Question,

Naser Ali sunhelp at sunhelp.org
Fri Mar 23 12:36:40 CST 2001


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0B3C8.333D4B60
Content-Type: text/plain;
	charset="iso-8859-1"

Thanks every one who responded.

 I cam up with an alternative way of doing what I have been asking in my
 original post,
 
 the first script calls for a second script for sleep function, if ctrl+c is
 pressed it will come out of sleep and continue its execution, below is the
 code for both as an example.
 
 ###############################
 #!/usr/bin/ksh
 
 for i in 1 2 3 4 5 6 7 8 9
 do
 touch $i
 . sleepy.sh
 done
 ################################
 #sleepy.sh
 #!/usr/bin/ksh
 
 function settrap {
 #while true
 do
 sleep 5
 done
 }
 
 trap 'print \`press control-C!\`' INT
 settrap
 print 'exiting....'
 #######################################

Aali Naser


-----Original Message-----
From: bscanlan at irish-times.com [mailto:bscanlan at irish-times.com]
Sent: Friday, March 23, 2001 5:18 AM
To: sunhelp at sunhelp.org
Subject: Re: [SunHELP] Scripting Question,


On Thu, Mar 22, 2001 at 11:04:21AM -0500, Naser Ali wrote:
> I have a shell script which in one stage o its run sleeps for defined time
> period (which is hard coded).
> I want the script to sleep and continue after the sleep time, but if a key
> on the key board is pressed it should come out of the sleep and continue
> before it completes the sleep cycle.

Sounds like a job for Expect.
http://expect.nist.gov/

Something like this example would work!
http://expect.nist.gov/scripts/timed-choice

Well worth taking a look at Expect, it's very cool.

-- 
Brian Scanlan, Systems Administrator.
Irish Times New Media - http://www.ireland.com
_______________________________________________
SunHELP maillist  -  SunHELP at sunhelp.org
http://www.sunhelp.org/mailman/listinfo/sunhelp

------_=_NextPart_001_01C0B3C8.333D4B60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>RE: [SunHELP] Scripting Question,</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>Thanks every one who responded.</FONT>
</P>

<P><FONT SIZE=3D2> I cam up with an alternative way of doing what =
I have been asking in my</FONT>
<BR><FONT SIZE=3D2> original post,</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> the first script calls for a second script for =
sleep function, if ctrl+c is</FONT>
<BR><FONT SIZE=3D2> pressed it will come out of sleep and continue =
its execution, below is the</FONT>
<BR><FONT SIZE=3D2> code for both as an example.</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> ###############################</FONT>
<BR><FONT SIZE=3D2> #!/usr/bin/ksh</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> for i in 1 2 3 4 5 6 7 8 9</FONT>
<BR><FONT SIZE=3D2> do</FONT>
<BR><FONT SIZE=3D2> touch $i</FONT>
<BR><FONT SIZE=3D2> . sleepy.sh</FONT>
<BR><FONT SIZE=3D2> done</FONT>
<BR><FONT SIZE=3D2> ################################</FONT>
<BR><FONT SIZE=3D2> #sleepy.sh</FONT>
<BR><FONT SIZE=3D2> #!/usr/bin/ksh</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> function settrap {</FONT>
<BR><FONT SIZE=3D2> #while true</FONT>
<BR><FONT SIZE=3D2> do</FONT>
<BR><FONT SIZE=3D2> sleep 5</FONT>
<BR><FONT SIZE=3D2> done</FONT>
<BR><FONT SIZE=3D2> }</FONT>
<BR><FONT SIZE=3D2> </FONT>
<BR><FONT SIZE=3D2> trap 'print \`press control-C!\`' INT</FONT>
<BR><FONT SIZE=3D2> settrap</FONT>
<BR><FONT SIZE=3D2> print 'exiting....'</FONT>
<BR><FONT SIZE=3D2> #######################################</FONT>
</P>

<P><FONT SIZE=3D2>Aali Naser</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>-----Original Message-----</FONT>
<BR><FONT SIZE=3D2>From: bscanlan at irish-times.com [<A =
HREF=3D"mailto:bscanlan at irish-times.com">mailto:bscanlan at irish-times.com=
</A>]</FONT>
<BR><FONT SIZE=3D2>Sent: Friday, March 23, 2001 5:18 AM</FONT>
<BR><FONT SIZE=3D2>To: sunhelp at sunhelp.org</FONT>
<BR><FONT SIZE=3D2>Subject: Re: [SunHELP] Scripting Question,</FONT>
</P>
<BR>

<P><FONT SIZE=3D2>On Thu, Mar 22, 2001 at 11:04:21AM -0500, Naser Ali =
wrote:</FONT>
<BR><FONT SIZE=3D2>> I have a shell script which in one stage o its =
run sleeps for defined time</FONT>
<BR><FONT SIZE=3D2>> period (which is hard coded).</FONT>
<BR><FONT SIZE=3D2>> I want the script to sleep and continue after =
the sleep time, but if a key</FONT>
<BR><FONT SIZE=3D2>> on the key board is pressed it should come out =
of the sleep and continue</FONT>
<BR><FONT SIZE=3D2>> before it completes the sleep cycle.</FONT>
</P>

<P><FONT SIZE=3D2>Sounds like a job for Expect.</FONT>
<BR><FONT SIZE=3D2><A HREF=3D"http://expect.nist.gov/" =
TARGET=3D"_blank">http://expect.nist.gov/</A></FONT>
</P>

<P><FONT SIZE=3D2>Something like this example would work!</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://expect.nist.gov/scripts/timed-choice" =
TARGET=3D"_blank">http://expect.nist.gov/scripts/timed-choice</A></FONT>=

</P>

<P><FONT SIZE=3D2>Well worth taking a look at Expect, it's very =
cool.</FONT>
</P>

<P><FONT SIZE=3D2>-- </FONT>
<BR><FONT SIZE=3D2>Brian Scanlan, Systems Administrator.</FONT>
<BR><FONT SIZE=3D2>Irish Times New Media - <A =
HREF=3D"http://www.ireland.com" =
TARGET=3D"_blank">http://www.ireland.com</A></FONT>
<BR><FONT =
SIZE=3D2>_______________________________________________</FONT>
<BR><FONT SIZE=3D2>SunHELP maillist  -  =
SunHELP at sunhelp.org</FONT>
<BR><FONT SIZE=3D2><A =
HREF=3D"http://www.sunhelp.org/mailman/listinfo/sunhelp" =
TARGET=3D"_blank">http://www.sunhelp.org/mailman/listinfo/sunhelp</A></F=
ONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C0B3C8.333D4B60--



More information about the SunHELP mailing list