Help needed writing small program -- possible? 
Author Message
 Help needed writing small program -- possible?

        If anyone can help me out at all, I'd really appreciate it.  I
need a way to automatically close a DOS Session at a specified time
(3am).  The DOS Session would be idle, so nothing would be lost.  After
it is closed, I need OS/2 to shutdown.

        Or, I suppose a different way of doing the same thing would be to
execute the shutdown command and somehow tell OS/2 to close any windows
that are open before shutting down.

        Thank you.



Sun, 23 Nov 1997 03:00:00 GMT  
 Help needed writing small program -- possible?

Quote:
>    If anyone can help me out at all, I'd really appreciate it.  I
>need a way to automatically close a DOS Session at a specified time
>(3am).  The DOS Session would be idle, so nothing would be lost.  After
>it is closed, I need OS/2 to shutdown.

>    Or, I suppose a different way of doing the same thing would be to
>execute the shutdown command and somehow tell OS/2 to close any windows
>that are open before shutting down.

You may want to look at the  CHECK_DEAMONS.CMD from
Turgut Kalfaoglu. You find it on Hobbes in the REXX
directory (/dev32/rexx if I recall it right).

It does not exactly what you want, but it would be
a good start, cause it is able to kill/start processes.

Oliver
--


WWW: http://fub46.zedat.fu-berlin.de:8080/~oheiabbd



Sun, 23 Nov 1997 03:00:00 GMT  
 Help needed writing small program -- possible?

Quote:

>       If anyone can help me out at all, I'd really appreciate it.  I
> need a way to automatically close a DOS Session at a specified time
> (3am).  The DOS Session would be idle, so nothing would be lost.  After
> it is closed, I need OS/2 to shutdown.

Here is my solution. I've been using it for months without problems.
I have a timer which turns on my networked office PC at 2:30am, then
CRON starts a souper session for fetching news and mail at 3:00am,
then my Rexx code starts an orderly shutdown later.

The code below is self documenting. You need the YdbaUtil (RXU) function
package by Dave Boll. As an alternative shutdown command you could equally
use that supplied with Warp.

==========================================================================
/*  KILL_ALL_PROCESSES_AND_SHUTDOWN.CMD  */


 This program will kill all running processes and shutdown the system.

 This program requires a freeware package (SHUTDOWN.EXE) available from
 many sources, including ftp-os2.nmsu.edu, ftp-os2.cdrom.com and the

 the source code (hint: ftp-os2.nmsu.edu:/os2/textutil/shutdwn5.zip).
 It also requires the RXU or YDBAUTIL function package for Rexx.
 The required version is 1.7 or above. It also is a freeware package,
 available as RXU17.ZIP at the same archive sites as above
 (hint: ftp-os2.nmsu.edu:/os2/dev32/rexx/rxu17.zip).

************************************************************************/

Call RxFuncAdd 'SysSleep','RexxUtil','SysSleep'
Call RxFuncAdd 'RxYdbautilinit','YdbaUtil','RxYdbautilinit'
Call RxYdbautilinit

seconds = 2    /* Number of seconds to wait after killing deamons */

thisproc_pid = word( RxProcid(), 1 )    /* Get this process' PID (decimal) */

dosrc = RxQProcStatus('ps.')            /* Get the process list */
nofpr = ps.0P.0                         /* number of running processes */
do n = 1 to nofpr
  /* skip its own running process */
  if D2X(thisproc_pid,4) = Translate(ps.0P.n.1) then iterate
  /* do not kill the WPS */
  if Pos('PMSHELL', ps.0P.n.6) > 0 then iterate
  /* otherwise, kill it! */
  killrc = RxKillProcess(X2D(ps.0P.n.1))
  Call SysSleep 1
end /* do */

Call SysSleep seconds   /* wait for completion */

/* Start SHUTDOWN in another session */
strc = RxStartSession('SHUTDOWN.EXE','','I','B')

EXIT
==========================================================================

There are many Unix-like cron programs available.
If you want an all-Rexx solution you could use the following code.
The only change to the original code was a "start /C /MIN" instead
of a "detach".

==========================================================================
/* CRON.CMD -- cheap UNIX cron clone for OS/2

signal on halt
call rxFuncAdd 'sysSleep', 'rexxUtil', 'sysSleep'

say 'CRON started' date() time()
do forever

  /* determine current time and date */
  currMin = time('m')-time('h')*60
  currHour = time('h')
  today = date('o')
  parse var today currYear '/' currMonth '/' currDay
  today = date('w')
  currDow = wordPos(today,'Sunday Monday Tuesday Wednesday Thursday Friday Saturday')-1

  /* Parse and check the crontab file */
  line = lineIn('crontab',1)
  do while line<>''
    parse var line minutes hours days months dows command
    isMin   = matches(minutes, currMin)
    isHour  = matches(hours, currHour)
    isDay   = matches(days,currDay)
    isMonth = matches(months,currMonth)
    isDow   = matches(dows,currDow)
    if isMin & isHour & isDay & isMonth & isDow
      then do
        say currMin'm' currHour'h' currDay'd' currMonth'm' currDow'w:' command

      end
    line = lineIn('crontab')
  end
  call stream 'crontab','c','close'
  call sysSleep 60-(time('s')-time('m')*60)

end  /* main loop */

matches:
args = arg(1)
if args='*' then return 1
matched = 0
parse var args value ',' args
do while value<>''
  if value=arg(2) then matched = 1
  parse var value from '-' to
  if from<=arg(2) & arg(2)<=to then matched = 1
  parse var args value ',' args
end
return matched

halt:
say ''
say 'CRON stopped' date() time()

/* end of file */
==========================================================================

Hope this helps.
Good luck.
--

Michele Marziani


 * Dipartimento di Fisica               Telephone: +39 532 781823 *
 * 44100 Ferrara - ITALY                      Fax: +39 532 781810 */



Thu, 27 Nov 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. i need help to write a cobol program as soon as possible

2. need help to write a cobol program,as soon as possible

3. Help! Need Eiffel small example programs

4. Need help on small programming problem.

5. smallest MVC program possible

6. Need help writing host program using LabView.

7. I need help with this program written in Fortran77

8. Help needed with writing a short PROGRAM.

9. Newbie wants to write a small program...

10. Small Programs written in SmallTalk or Eiffel

11. Small Programs written in SmallTalk or Eiffel

12. Small MODULA 2 program needed ...

 

 
Powered by phpBB® Forum Software