• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Call SYSSLEEP 60 - do not work after reboot

Started by Andi, 2010.05.25, 20:44:36

Previous topic - Next topic

Andi

Hi,
I've a REXX script -

/* script to optain the own IP address and store it in a log file with time stamp */
LogFile='E:\log\OwnIP.log'
DomainName='myname.selfip.net'

/* wait 60s to let DSL connection start and in case of error repeat every 60s */
call SYSSLEEP 60

'@call ping 'DomainName' 1000 1 >ping_tmp.txt'
...
which runs fine when starting from command line but fails when starting from the startup folder or from startup.cmd. Error message is

     6 +++   Call SYSSLEEEP 60;
REX0043: Error 43 running M:\batch\GetSelfIP.cmd, line 6: Routine not found

First version I had 'call SYSSLEEP(60)' with braces but didn't work either. I wonder if there is something to load before using SYSSLEEP but didn't find it in the documentation. Any help appreciated

warunyan

Isn't below forgot?

Call RXFUNCADD 'SysLoadFuncs','REXXUTIL','SysLoadFuncs'
Call SysLoadFuncs

Andi

Thx, will try it. That's the kind of information I've searched for in the help files. Unfortunately the REXX help is kind of useless compared to most other language docs I've read. I find it rather hard to start REXX programming with the help files I found installed on my eCS system. Now I've new buzzwords to search for...

jep

Quote from: Andi on 2010.05.26, 09:56:11
Thx, will try it. That's the kind of information I've searched for in the help files. Unfortunately the REXX help is kind of useless compared to most other language docs I've read. I find it rather hard to start REXX programming with the help files I found installed on my eCS system. Now I've new buzzwords to search for...

The documentation mention built in "Functions", basic functions that are parts of the Rexx langauge itself.

Functions that begin with "Sys" is part of the RexxUtils package and extend Rexx and has to be loaded in your script before you can use them, the docs therefore mention those in a separate branch. The code waruyan mention can be found directly in the tree view (Contents Tab) for the "REXX Utility Functions (RexxUtils)" package, that belong to that perticular package and what you can do with them under that branch.

The documentation for Classic Rexx is easier to read (says "OS/2 Procedures Langauge 2/REXX" in the titelbar) than "Object REXX Reference". The documentation may take some time to get accustomed to, but it do provide alot of info you may need in a convenient way.

"Rexx Tips & Tricks" give you the extra-in-depth-knowledge that the basic documentation has left out.




'@call ping 'DomainName' 1000 1 >ping_tmp.txt'

You can later also try to send the output to a rexxqueue and a rexx variable instead of a file if you'd like that.



call somehing()
(paranthesis after first function name) was allowed in earlier releases of Regina (<3.2?) but that doesn't follow the standard. Use (...) with
say my_own_function(...)
If my_other_function(...) = 1 Then
etc. where "..." can be any parameter you want.

Andi

Quote from: jep on 2010.05.26, 15:00:44
....
Functions that begin with "Sys" is part of the RexxUtils package and extend Rexx and has to be loaded in your script before you can use them, the docs therefore mention those in a separate branch. The code waruyan mention can be found directly in the tree view (Contents Tab) for the "REXX Utility Functions (RexxUtils)" package, that belong to that perticular package and what you can do with them under that branch.

The documentation for Classic Rexx is easier to read (says "OS/2 Procedures Langauge 2/REXX" in the titelbar) than "Object REXX Reference". The documentation may take some time to get accustomed to, but it do provide alot of info you may need in a convenient way.

"Rexx Tips & Tricks" give you the extra-in-depth-knowledge that the basic documentation has left out.



As most times if you know it it's quite easy to find. I found out too, that with most sys functions there's also example code but not with syssleep. There's even not mentioned that seconds must not be an integer but 0.55 is accepted too. Which leads me to conclude this document is rather superficially. But probably this is the usual hurdle when digging into something new.

Quote
'@call ping 'DomainName' 1000 1 >ping_tmp.txt'

You can later also try to send the output to a rexxqueue and a rexx variable instead of a file if you'd like that.
I send it to a file cause I've reused working code which reads the output afterwards -

'@call ping 'DomainName' 1000 1 >ping_tmp.txt'
file = 'ping_tmp.txt'
DO FOREVER
    IF lines(file) > 0 THEN DO
        line = LEFT(LINEIN(file,1,1),25)
        OutLine = DATE('S')' 'TIME()' 'line' --> 'LINEIN(file)
        ret=LINEOUT(LogFile,OutLine)
        say OutLine
...
If I redirect the output to a variable, can I read this variable line by line too?

Thanks,

jep

Hello,
the documentation for classic rexx was written way before the current realease of RexxUtil and the support for decimal numbers instead of full seconds (integer) was therefore not even thought of in that release.

RexxUtil that come with eCS is at the level of Object Rexx and therefore contain alot of extra neat stuff that you can need to read about in either the Object Rexx help or Rexx Tips & Tricks.

Regarding queues, Yes, the output can be read line by line with something like

/* Clear session queue in case it contain "garbage" from a previous run */
'@rxqueue SESSION /CLEAR'

/* Try to determine the scanner, send output to the app rexxqueue, that place it in the rexx queue */
'@scanimage -L | rxqueue SESSION /FIFO'
/* Read the first line from the rexx queue */
parse value LINEIN( 'QUEUE:' ) with 'device `'cfg.device"' is a" cfg.scanner.manufacturer cfg.scanner.name cfg.scanner.model cfg.scanner.type 'scanner'

//Jan-Erik

RobertM

Quote from: jep on 2010.05.27, 18:03:03
Hello,
the documentation for classic rexx was written way before the current realease of RexxUtil and the support for decimal numbers instead of full seconds (integer) was therefore not even thought of in that release.

RexxUtil that come with eCS is at the level of Object Rexx and therefore contain alot of extra neat stuff that you can need to read about in either the Object Rexx help or Rexx Tips & Tricks.

Regarding queues, Yes, the output can be read line by line with something like

/* Clear session queue in case it contain "garbage" from a previous run */
'@rxqueue SESSION /CLEAR'

/* Try to determine the scanner, send output to the app rexxqueue, that place it in the rexx queue */
'@scanimage -L | rxqueue SESSION /FIFO'
/* Read the first line from the rexx queue */
parse value LINEIN( 'QUEUE:' ) with 'device `'cfg.device"' is a" cfg.scanner.manufacturer cfg.scanner.name cfg.scanner.model cfg.scanner.type 'scanner'

//Jan-Erik

Correct... 5 decimal digits are safe in eCS and WSeB and MCP and ACP for any version of REXX included (CREXX or OREXX). Someplace I have a post on the subject. Exceeding a certain number of digits after the decimal place will make CREXX or OREXX treat the number as a zero, meaning the SysSleep statement will not do anything at all. The number is 6 or 7 depending on REXX version, thus I stick with 5 or less digits to ensure proper program operation.

This of course will create problems with older versions of CREXX (ie: on older OS/2 installs such as base Warp 4 no FP and Warp 3 or OS/2 2.0) where it will not accept a decimal number and the smallest number usable is 1 (as in one second). Determination can be made of such capabilities by querying the REXX or REXXUTIL version and then setting a "MinimalWait" variable to either 1 or to some decimal number, then using that variable in any "wait as short a period as possible" SysSleep statement.

An example (NOT actual code - dont have the time to write such now) is this:

/* At Top Section of REXX program */
RxVer=CheckRexxVersion()

If RxVer>=BetterRexxUtilVerNumber Then
  MinimalWait=.01
Else
  MinimalWait=1



/* Someplace below in main code or function calls */
Do Something (Loop, etc)
  Some instruction(s)
  rtc=SysSleep(MinimalWait)
End (Loop, etc)

Do MoreStuff (Loop, etc)
  Some instruction(s)
  rtc=SysSleep(MinimalWait)
End (Loop, etc)



In each, MinimalWait will be properly defined determined by REXX version, and then whenever used, will ensure a compatible, working number is sent to SysSleep.

Which version support what? Notta clue. I dont have any older REXX installations running. One would have to find the version numbers and subsitute it in the psuedo-code above where "BetterRexxUtilVerNumber" is located.

But basically, it is that easy.


|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|


Andi

Quote from: jep on 2010.05.27, 18:03:03
...
Regarding queues, Yes, the output can be read line by line with something like

/* Clear session queue in case it contain "garbage" from a previous run */
'@rxqueue SESSION /CLEAR'

/* Try to determine the scanner, send output to the app rexxqueue, that place it in the rexx queue */
'@scanimage -L | rxqueue SESSION /FIFO'
/* Read the first line from the rexx queue */
parse value LINEIN( 'QUEUE:' ) with 'device `'cfg.device"' is a" cfg.scanner.manufacturer cfg.scanner.name cfg.scanner.model cfg.scanner.type 'scanner'

//Jan-Erik
Thx. I've now used a queue within Rexx successfully with your sample. Works well on my main machine. Problem is, the same script does not run on a fresh installed eCS2.0GA. Before I dig in deeper and check all rc values one question -

Is there a known missing prerequisite in eCS2.0 which prevents queues? I mean some rexx*dll which I've to install manually?


jep

No, you don't have to install anything extra to use it, but do notice that you need the executable scanimage (from TAME/2) installed and functional, available in the same folder to make the example work.

Please do try the following example from "OS/2 Procedures language 2/REXX" help instead.

Cut & paste:
/*                                                                */
/*        push/pull WITHOUT multiprogramming support         */
/*                                                                */
push date() time()          /* push date and time            */
do 1000                     /* lets pass some time           */
  nop                       /* doing nothing                 */
end                         /* end of loop                   */
pull a b .                  /* pull them                     */
say 'Pushed at ' a b ', Pulled at ' date()
time() /* say now and then */

/*                                                                    */
/*              push/pull WITH multiprogramming support               */
/*            (no error recovery, or unsupported env tests            */
/*                                                                    */
newq = RXQUEUE('Create')    /* create a unique queue           */
oq = RXQUEUE('Set',newq)    /* establish new queue             */
push date() time()          /* push date and time              */
do 1000                     /* lets spend some time            */
  nop                       /* doing nothing                   */
end                         /* end of loop                     */
pull a b .                  /* get pushed info                 */
say 'Pushed at ' a b ', Pulled at ' date() time() /* tell user     */
call RXQUEUE 'Delete',newq         /* destroy unique queue created  */
call RXQUEUE 'Set',oq         /* reset to default queue (not required) */


//Jan-Erik

Andi

I have -
   
'@myip.exe | rxqueue SESSION /FIFO'
        line = LEFT(LINEIN( 'QUEUE:' ),15)

which perfectly works. Problem was a logical error which I overlooked when I changed it from writing/reading in a file to queue.

Question - will line =.... wait until there is data in the queue? And if yes, when myip.exe do not put anything into the queue my script will wait forever, right? How can I check if there's anything in the queue?

Thx.

RobertM

IIRC, no. You would need to add some additional code to check the queue for data, and then upon data, read it from the queue. IIRC, I use a simple "Do Forever..." loop WITH a SysSleep of .01 to ensure I do not peg the CPU or raise it anything noticeable.

I believe there are examples either in the CREXX/OREXX docs, or on Hobbes in the RxQueue examples there if you cannot figure out how to do it (or Thomas doesn't post a solution ;) ). If none of those occur, then if I have some time tomorrow, I will try to dig up the code I used for queue checking.

Rob


|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|


CDRWSel

#11
Quote from: Andi on 2010.08.05, 20:41:02
I have -
   
'@myip.exe | rxqueue SESSION /FIFO'
       line = LEFT(LINEIN( 'QUEUE:' ),15)

which perfectly works. Problem was a logical error which I overlooked when I changed it from writing/reading in a file to queue.

Question - will line =.... wait until there is data in the queue? And if yes, when myip.exe do not put anything into the queue my script will wait forever, right? How can I check if there's anything in the queue?

Thx.

Try something like this:
(create newq routine)
'@myip.exe | rxqueue SESSION /FIFO'
Do queued()
   parse pull line
   ... add code to format the taken line as you want...
End
(delete newq routine)

RobertM



|
|
Kirk's 5 Year Mission Continues at:
Star Trek New Voyages
|
|