How to "sleep" within GAWK on Win32 ? 
Author Message
 How to "sleep" within GAWK on Win32 ?

Hello,

is there a simple way to issue a sleep or wait command/function within
a GAWK (3.1) script which runs on a Windoze (2000) box?
It should wait for X minutens and then comeback/continue. Doing all
kind of loops with time functions isn't a good idea since the "sleep"
task should consume as few CPU time as possible (ie AWK should be
sleeping :-).

In UNIX this is trivial. Not so in Windoze because there's no wait or
sleep dos-command which I could call per system("xzy").

-ric



Sun, 01 May 2005 01:17:19 GMT  
 How to "sleep" within GAWK on Win32 ?

Quote:

>Hello,

>is there a simple way to issue a sleep or wait command/function within
>a GAWK (3.1) script which runs on a Windoze (2000) box?
>It should wait for X minutens and then comeback/continue. Doing all
>kind of loops with time functions isn't a good idea since the "sleep"
>task should consume as few CPU time as possible (ie AWK should be
>sleeping :-).

>In UNIX this is trivial. Not so in Windoze because there's no wait or
>sleep dos-command which I could call per system("xzy").

Simple answer: Get a sleep for Windows.  One way to do this is to get it
from Cygwin (*).  Another way is to use the Windows standard command
"choice" - although I have not personally verified what exactly "choice"
does in terms of CPU cycles while it is waiting.

More involved answer: Depending on which version of GAWK for Windows you
are running and/or how handy you are with compilers, you may be able to add
a sleep() function to the language.  This should be do-able in GAWK 3.2,
when the Cygwin port will have the ability to link to DLLs.  It would be
possible currently, I believe, by hacking the source.

Best answer: Switch to TAWK, which has, of course, a sleep() builtin.

(*) Don't be misled into thinking that I am suggesting that you install the
whole Cygin kit and kaboodle.  You can just fetch sleep.exe from the
collection and use it standalone.



Sun, 01 May 2005 02:04:22 GMT  
 How to "sleep" within GAWK on Win32 ?
Hi Richard,

For 'sleep' in Windows you could use Windows command 'choice', e.g:

c:\>choice /N /T:N,05 Sleep 5 seconds


Quote:
> Hello,

> is there a simple way to issue a sleep or wait command/function within
> a GAWK (3.1) script which runs on a Windoze (2000) box?
> It should wait for X minutens and then comeback/continue. Doing all
> kind of loops with time functions isn't a good idea since the "sleep"
> task should consume as few CPU time as possible (ie AWK should be
> sleeping :-).

> In UNIX this is trivial. Not so in Windoze because there's no wait or
> sleep dos-command which I could call per system("xzy").

> -ric



Sun, 01 May 2005 06:49:31 GMT  
 How to "sleep" within GAWK on Win32 ?

Quote:

> Hi Richard,

> For 'sleep' in Windows you could use Windows command 'choice', e.g:

> c:\>choice /N /T:N,05 Sleep 5 seconds

Hi Joseph,

thanks for your reply.
Unfortunately I can't find the "choice" command within Windows-2000
Professional which I use. It's not mentioned in the Windows help,
where all commands (like "pause" or "subst") are listed, and so does
the dosbox/shell report an error.

I've looked at M$' Win2000 Resource Kit, which provides some further
commands. The ones which are free are useless for me and the ones I
could need do cost money: among them is a sleep command. :-|  Windoze
sucks.

Anyway, while browsing the Resource Kit because of searching your
mentioned "choice" command I found this:
http://www.microsoft.com/technet/prodtechnol/windows2000serv/support/...
It looks like it works, but it's strange anyway and I don't understand
why there's no simple sleep command in Windoze.

However thanks again, you helped me a lot. :-)

-ric



Sun, 01 May 2005 20:36:54 GMT  
 How to "sleep" within GAWK on Win32 ?
[..]

Quote:
> Simple answer: Get a sleep for Windows.  

Hi Kenny,

thanks for your reply. Yes, this is a solution. I'll have a look at
the Cygwin, especially the useful standalone exe's.
However usually I try to solve the batch problems with the usage of
GAWK without any further exes, dlls, etc. Also because if I run them
within a Windows network I want to keep it as small and maintainable
as possible.

Compiling I won't do. :-)  At the moment, I'm just a GAWK user, no
programmer. ;-)

Quote:
> Best answer: Switch to TAWK, which has, of course, a sleep() builtin.

Sounds very nice.
However I'm such a fan of the GNU philosophy. I know I'm going to
investigate if our small bureau can install some Linux machines so
that finally we got plenties of "sleep" commands and all the other
important ones ready to go and for free. And also GAWK would be there
on any single Linux machine, also. :-)


Sun, 01 May 2005 20:43:33 GMT  
 How to "sleep" within GAWK on Win32 ?


Quote:
> Hello,

> is there a simple way to issue a sleep or wait command/function within
> a GAWK (3.1) script which runs on a Windoze (2000) box?
> It should wait for X minutens and then comeback/continue. Doing all
> kind of loops with time functions isn't a good idea since the "sleep"
> task should consume as few CPU time as possible (ie AWK should be
> sleeping :-).

Two zonky trix to try and reach your aims :

1. use "time" and "AT" commands
2. use echo ^G >/NUL in a loop to complete as much times
the duration of a beep you want.
(caveat: The beep duration is fixed when heard
but I am not sure about it if pushed to /NUL ...)

Tell me about it ?



Sun, 01 May 2005 21:45:31 GMT  
 How to "sleep" within GAWK on Win32 ?


Quote:
> [..]
> > Simple answer: Get a sleep for Windows.

> Hi Kenny,

> thanks for your reply. Yes, this is a solution. I'll have a look at
> the Cygwin, especially the useful standalone exe's.
> However usually I try to solve the batch problems with the usage of
> GAWK without any further exes, dlls, etc. Also because if I run them
> within a Windows network I want to keep it as small and maintainable
> as possible.

> Compiling I won't do. :-)  At the moment, I'm just a GAWK user, no
> programmer. ;-)

> > Best answer: Switch to TAWK, which has, of course, a sleep() builtin.

> Sounds very nice.
> However I'm such a fan of the GNU philosophy. I know I'm going to
> investigate if our small bureau can install some Linux machines so
> that finally we got plenties of "sleep" commands and all the other
> important ones ready to go and for free. And also GAWK would be there
> on any single Linux machine, also. :-)

Hi, Richard -

Quote:
> However usually I try to solve the batch problems with the usage of
> GAWK without any further exes, dlls, etc. Also because if I run them
> within a Windows network I want to keep it as small and maintainable
> as possible.

You say "IF I run them in a Windows network..."  It sounds like you are
right now exclusively Windows.  Why make your life harder by trying to
learn, yourself, all the *nix commands, and then hire people to maintain the
code that (let's face it) are probably going to be Windows-centric?  You are
creating an environment where even your junior system admins will need to be
conversant in both Windows and *nix.  Not a bad thing, but does your
bureau's administration know what this will do to cost and productivity?
(Yeah, the smart-ass answer is "Increase it! :)"  But you should look a
little deeper than that.  But maybe AWK's record-and-field orientation holds
a particular promose for your task.  Since you haven't told us what you do,
other than batch problems, only you know that answer.)

If you are not tied to Windows, switch now completely to *nix.  If you are
tied to Windows, consider staying "in-band" with your solution, and work
with the Windows Scripting Host, and its Visual Basic Scripting Edition and
J Script.  WSH is intrinsic to MS systems after W95, and present even on W95
with IE5+, or specific downloads.  And they get you access to COM to some
degree.  This gives you, architecturaly, many more options than just
function libraries included on the awk command line.

Most of all, WSH keeps your maintainers using MS technology on an MS network
running MS operating systems, and, as horrible as MS is (that's why you
should switch now to *nix), homogeneity will lead to more ease, and thus a
lower cost, of maintenance.

If you insist on going the *nix way, several other groups and people have
compiled small standalone versions of most all of the *nix text and system
utilities.  Don't stop looking when you get to CygWin.

    - Dan



Mon, 02 May 2005 00:03:14 GMT  
 How to "sleep" within GAWK on Win32 ?
He said he's using W2K, not W98. Winblows 2000 doesn't have the CHOICE command.
Quote:

> Hi Richard,

> For 'sleep' in Windows you could use Windows command 'choice', e.g:

> c:\>choice /N /T:N,05 Sleep 5 seconds



> > Hello,

> > is there a simple way to issue a sleep or wait command/function within
> > a GAWK (3.1) script which runs on a Windoze (2000) box?
> > It should wait for X minutens and then comeback/continue. Doing all
> > kind of loops with time functions isn't a good idea since the "sleep"
> > task should consume as few CPU time as possible (ie AWK should be
> > sleeping :-).

> > In UNIX this is trivial. Not so in Windoze because there's no wait or
> > sleep dos-command which I could call per system("xzy").

> > -ric



Mon, 02 May 2005 05:10:43 GMT  
 How to "sleep" within GAWK on Win32 ?

Quote:

>He said he's using W2K, not W98. Winblows 2000 doesn't have the CHOICE
>command.

You are right.
Another example of MS doing what MS does best: reverse progress.
I wonder why they took it out.

I got confused about this b/c our network admins had put a copy of
CHOICE.EXE in Z:\PUBLIC (Netware's public dir), so it came up (very slowly)
for me in W2K.  I then copied it from Z:\PUBLIC to C:\BIN (on PATH) and it
worked fine thereafter.  You are right that it isn't in W2K natively, but
if you get it from W98, it works fine under 2K.



Mon, 02 May 2005 06:15:54 GMT  
 How to "sleep" within GAWK on Win32 ?
Quote:


>>He said he's using W2K, not W98. Winblows 2000 doesn't have the CHOICE
>>command.

>You are right.
>Another example of MS doing what MS does best: reverse progress.
>I wonder why they took it out.

...

It wasn't in WinNT4, and Win2K is the spawn of WinNT rather than of Win9x.
WinNT/Win2K do come with QBASIC, and it's possible to kludge a sleep
work-alike in QBASIC.

echo sleep %1: system > %TEMP%\~kludge~.bas
qbasic /run %TEMP%\~kludge~.bas
del %TEMP%\~kludge~.bas



Tue, 03 May 2005 04:43:46 GMT  
 How to "sleep" within GAWK on Win32 ?

...

Quote:
>It wasn't in WinNT4, and Win2K is the spawn of WinNT rather than of Win9x.

That's true.  Still, I thought MS's whole idea was to merge the two lines
(in particular, W2K was supposed to be that merging).  Color me surprised.

Quote:
>WinNT/Win2K do come with QBASIC, and it's possible to kludge a sleep
>work-alike in QBASIC.



>echo sleep %1: system > %TEMP%\~kludge~.bas
>qbasic /run %TEMP%\~kludge~.bas
>del %TEMP%\~kludge~.bas

That's cool.  Unfortunately, there is no QBASIC on my W2K Professional box.
Typing "qbasic" at the command prompt gets a "command not found" (as does
"start qbasic") and "dir C:\*basi* /s" doesn't turn up anything
interesting.


Tue, 03 May 2005 06:24:57 GMT  
 How to "sleep" within GAWK on Win32 ?
...
Quote:
>That's true.  Still, I thought MS's whole idea was to merge the two lines
>(in particular, W2K was supposed to be that merging).  Color me surprised.

...

I thought WinXP Home/Pro was the merger, since WinME is definitely the
unholy spawn of Win9x and came out after Win2K.

Quote:
>That's cool.  Unfortunately, there is no QBASIC on my W2K Professional box.
>Typing "qbasic" at the command prompt gets a "command not found" (as does
>"start qbasic") and "dir C:\*basi* /s" doesn't turn up anything

Swell. Either MS dropped it, you have to choose it specifically (it isn't
installed by default) during setup, or you have to install after OS
installation. Easier to download and install the GnuWin32 shellutils package
on SourceForge, which includes sleep.exe.


Tue, 03 May 2005 09:21:10 GMT  
 How to "sleep" within GAWK on Win32 ?

Quote:

> ...
> >That's true.  Still, I thought MS's whole idea was to merge the two
lines
> >(in particular, W2K was supposed to be that merging).  Color me
surprised.
> ...

> I thought WinXP Home/Pro was the merger, since WinME is definitely the
> unholy spawn of Win9x and came out after Win2K.

Yes, Harlan, this is correct.  I wouldn't touch WinME with the
proverbial "barge pole" (and no amount of "it works for me"
protestations will convince me otherwise) given the number of times I've
had to rescue WinME machines back to a nice stable (for M$, you
understand) Win98SE for friends and colleagues.

Quote:
> >That's cool.  Unfortunately, there is no QBASIC on my W2K
Professional box.
> >Typing "qbasic" at the command prompt gets a "command not found" (as
does
> >"start qbasic") and "dir C:\*basi* /s" doesn't turn up anything

> Swell. Either MS dropped it, you have to choose it specifically (it
isn't
> installed by default) during setup, or you have to install after OS
> installation. Easier to download and install the GnuWin32 shellutils
package
> on SourceForge, which includes sleep.exe.

Well there is the alternative of finding a Win98SE machine and copying
over the command line tools like choice.  IME most of these Win98SE
command line tools, which do not have direct W2K equivalents, will run
"out of the box" under cmd.exe as they are what M$ calls Win32 (as
opposed to Win16 or Win32s) programs that should run correctly on any of
M$'s Win32 platforms.  Much as I hate disclaimers: Disclaimer: if you
choose to do this there are no guarantees of success or failure, nor do
I accept any responsibility for any consequential damage that may result
from your actions.

There are many tools on the Win98SE Resource Kit CD that fall into the
aforementioned Win32 category and so should work on W2K.  The Win98SE
set-up CD even contains some tools that will, IIRC, run quite happily
under W2K's cmd.exe, including, in \tools\oldmsdos, qbasic.exe,
qbasic.hlp and help.exe.  Once again: no guarantees and disclaimer still
applies.

HTH
--
Peter S Tillier
"Who needs perl when you can write dc and sokoban in sed?"



Tue, 03 May 2005 11:47:21 GMT  
 How to "sleep" within GAWK on Win32 ?
Starting to go OT, but XP Pro is the next step in the NT / 2K line. XP Home is the evolutionary dead end for 9x. At least that's what a Microslut told me.
Quote:


> ...
> >That's true.  Still, I thought MS's whole idea was to merge the two lines
> >(in particular, W2K was supposed to be that merging).  Color me surprised.
> ...

> I thought WinXP Home/Pro was the merger, since WinME is definitely the
> unholy spawn of Win9x and came out after Win2K.

> >That's cool.  Unfortunately, there is no QBASIC on my W2K Professional box.
> >Typing "qbasic" at the command prompt gets a "command not found" (as does
> >"start qbasic") and "dir C:\*basi* /s" doesn't turn up anything

> Swell. Either MS dropped it, you have to choose it specifically (it isn't
> installed by default) during setup, or you have to install after OS
> installation. Easier to download and install the GnuWin32 shellutils package
> on SourceForge, which includes sleep.exe.



Thu, 05 May 2005 20:51:20 GMT  
 How to "sleep" within GAWK on Win32 ?
Ugh, #2 looks real ugly. Would not be surprised if it crashed the box. I seem to recall a situation in some previous ver of MS OS where if you repeatedly did a redirect to the null device, you could exhaust resources and wedge the box.
Quote:



> > Hello,

> > is there a simple way to issue a sleep or wait command/function within
> > a GAWK (3.1) script which runs on a Windoze (2000) box?
> > It should wait for X minutens and then comeback/continue. Doing all
> > kind of loops with time functions isn't a good idea since the "sleep"
> > task should consume as few CPU time as possible (ie AWK should be
> > sleeping :-).

> Two zonky trix to try and reach your aims :

> 1. use "time" and "AT" commands
> 2. use echo ^G >/NUL in a loop to complete as much times
> the duration of a beep you want.
> (caveat: The beep duration is fixed when heard
> but I am not sure about it if pushed to /NUL ...)

> Tell me about it ?



Thu, 05 May 2005 20:54:57 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

2. Monitor "Sleep" Command

3. "Make Money, While You Sleep"

4. gawk 3.x: "static" extensions

5. gawk 3 patch by A. Robbins for index(.,"")==0 bug

6. Bug: gawk 3.0 fails to index(.,"")

7. Allowing " " within Amrita

8. "cvs commit" from within ruby

9. Pointers within "f77" under linux

10. Pointers within "f77" under linux

11. "windows" within frame

12. "current working directory" within a package

 

 
Powered by phpBB® Forum Software