Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Jan-Erik Lärka

Pages: [1] 2
1
Applications / PM app ClamDScan
« on: January 05, 2018, 07:52:37 pm »
It is mulithreaded* and use clamdscan to scan for various threats.

Use clamd on another machine if set up in the clamd.conf file.

Add it to Folder actions (XWP) and you can right click on a folder and scan the whole folder structure.

It tell you what file it has processed (percent and first number) and how many more files this and previous thread that has finished contain* and the total number of files to process in this folder/drive.

ETA: 5h is the Estimated Time of Arrival calculated on the number of files processed and the number of files left to process, not their sizes.

​You can also notice the subtle shine that pass over the progress bar. Add a copy of the DLL in the libpath so it can load and use the progress bar images.

It create a folder on the desktop called "Alert" with the files it find that contain
Malware Trojan Worm Downloader etc.
It attach the Icons it find based on the type name of the threat so one can design ones own icons and place them in the folder next to the executable.

It also add a comment to the file of what type of threat it has detected and set the association type to the same, thus somewhat reduce the ease to double-click-open the file.

*It use multi threading to speed up processing.
It first list files in the current folder and add those so it can start to scan almost right away (if the current folder doesn't contain many files). Then it hand over to up to 5 additional threads (if there are 5 or more sub folders present) to list the files there. As each thread finish, the progress bar and title bar information adjust itself to the information while it scan queued files.

2
Programming / htonl in REXX
« on: December 19, 2017, 07:19:59 pm »
The socket call translates a long integer from host-byte order to network-byte order.

Syntax
htonl( a )

Parameters
a
integer (whole) number to be converted to/from network-byte order (on little endian systems).

Description
htonl(...) call convert an host-byte order integer to internet network-byte order.
htonl(...) call also convert an internet network-byte order integer to host-byte order.

The internet network requires addresses and ports in network standard-byte order.
Use the htonl(...) call to convert the host integer representation of addresses and ports to internet network-byte order.

Returns
The translated integer

Example:
SAY htonl( 16384 )  //4194304
SAY htonl( 4194304 )  //16384

Code:
Code: [Select]
htonl: PROCEDURE
   hex = D2X( ARG( 1 ) )
   exp = ''
   DO i = 1 TO LENGTH( hex ) BY 8
      exp =  STRIP( TRANSLATE( '12345678', RIGHT( STRIP( SUBSTR( hex, i, 8 ) ), 8, '0' ), '78563412' ) )||exp
   END
RETURN X2D( exp )

ClamAV use it for zINSTREAM
Other applications that communicate over the network

Regards,
//Jan-Erik

3
Utilities / problems with sh.exe
« on: June 11, 2017, 10:13:43 pm »
I've successfully installed PostgreSQL in the past.
One has to use initdb.exe and the various executables to create databases, add tables, data and functions etc.
I decided to try once more, but now stumble on messages that sh.exe can't do this and that.
I've tried to rename ash, bash, dash to sh but the problem remain.
What has been changed and why? Fix?

Issue #164
initdb.exe from PostgreSQL apparently use sh.exe internally to initialize a new database structure.

Command line: initdb -E UTF8 -D D:/NLSTeam
Has worked in the past, but not now with installed libraries up to date according to ANPM.

Version: PostgreSQL 8.2.5 b2
Output:
sh.exe: 1: cannot create nul:: Directory nonexistent
fgets failure: No such file or directory
The program "postgres" is needed by initdb but was not found in the
same directory as "D:/Programs/postgres/bin/initdb".
Check your installation.
Couldn't initalize database

Version: PostgreSQL 9.1.7
Output:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale sv_SE.IBM-850.
could not determine encoding for locale "sv_SE.IBM-850": codeset is "IBM-850"
could not determine encoding for locale "sv_SE.IBM-850": codeset is "IBM-850"
The default text search configuration will be set to "swedish".

creating directory D:/NLSTeam ... ok
creating subdirectories ... ok
selecting default max_connections ... sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
10
selecting default shared_buffers ... sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
sh.exe: 1: cannot open nul:: No such file
sh.exe: 1: D:Programspgsqlbinpostgres.exe: not found
400kB
creating configuration files ... ok
creating template1 database in D:/NLSTeam/base/1 ... sh.exe: 1: D:Programspgsqlb
inpostgres.exe: not found
child process exited with exit code 127
initdb: removing data directory "D:/NLSTeam"
SYS1808:
The process has stopped. The software diagnostic
code (exception code) is 0005.
Couldn't initalize database

4
Applications / JAVA and https not possible
« on: September 04, 2016, 10:11:51 pm »
I'm trying to use java in OpenJDK6 to fetch packages for me, but it refuse since the cacert miss information.
How can I overcome this in OS/2 - eCS?
What do I have to do and how? (Step-by-step)

Code: [Select]
SDK Manager repository: manifest cache cleared.
Refresh Sources:
  Fetching https://dl.google.com/android/repository/addons_list-2.xml
  Failed to fetch URL https://dl.google.com/android/repository/addons_list-2.xml
, reason: peer not authenticated
  Fetched Add-ons List successfully
  Refresh Sources
  Fetching URL: https://dl.google.com/android/repository/repository-11.xml
  Failed to fetch URL https://dl.google.com/android/repository/repository-11.xml
, reason: SSLPeerUnverified peer not authenticated

5
Programming / NetRexx
« on: September 03, 2016, 06:55:20 pm »
I've tried to use NetRexx as it offer you to write
code in (some-kind-of-) Rexx that can be compiled
into JAVA byte code. It's apparently even possible
to use it to write apps for android...

I just had to rewrite the included script to better suit how
OpenJDK 6 in OS/2 work. Please do help me to verify
that the script behave well and handle various scenarios
properly.

You can even drop a folder and it should try to compile all
.nrx-files within (if the resulting command line length
doesn't exceed 1024 characters).

Place "NetRexxKing.png" and "NetRexxKing.ico" in the
NetRexx  folder. Place the script NRxC.cmd in the NetRexx \bin
- folder before you run it and let it create a program object
in the development folder or on the desktop.

Code: [Select]
/* Translate and compile a NetRexx program             */
/*                                                     */
/* use as:  NRxC hello [file2]...                      */
/*                                                     */
/*   which will use the NetRexx translator to          */
/*   translate hello.nrx to hello.java                 */
/*   then will use javac to compile hello.java         */
/*                                                     */
/* OPTIONS keywords may be added (with a -) before or  */
/* after the file specification, along with the extra  */
/* flags known to NetRexxC (such as -keep).   For      */
/* example:                                            */
/*                                                     */
/*    NRxC -keep -format -comments hello               */
/*                                                     */
/* Invoke with no parameters for a full list of flags. */
/*                                                     */
/* To run the class after compilation, specify -run as */
/* an option word.  Each file will be run in turn.     */
/*                                                     */
/*    NRxC -run hello                                  */
/*                                                     */
/* Multiple programs may be specified; in this case    */
/* they are all run (if requested) after all compiles. */
/*                                                     */
/* ----------                                          */
/* 1996.09.02 -- handle Warnings from NetRexxC (rc=1)  */
/* 1996.12.14 -- use COM.ibm.netrexx.process           */
/* 1998.05.25 -- pass NETREXX_JAVA setting to java.exe */
/* 2011.09.01 -- use org.netrexx.process               */
/* 2011.09.01 -- remove -xms4M                         */
/* 2016.08.30 -- Complete rewrite                      */

PARSE UPPER ARG uargs
PARSE ARG args

netrx.run = ( WORDPOS( '-RUN', uargs ) > 0 )
netrx.noc = ( WORDPOS( '-NOCOMPILE', uargs ) > 0 )
IF netrx.run THEN
DO
   PARSE VALUE uargs WITH pre'-RUN'post
   args = LEFT( args, LENGTH( pre ) )RIGHT( args, LENGTH( post ) )
END

PARSE SOURCE system . this
old_dir = DIRECTORY()

SELECT
   WHEN system = 'OS/2' THEN
   DO
      '@ECHO OFF'
      env = 'OS2ENVIRONMENT'

      /* Load RexxUtil Library */
      IF RxFuncQuery('SysLoadFuncs') THEN
      DO
         CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
         CALL SysLoadFuncs
      END
     
      CALL SysGetEA this, 'JAVA_PATH', 'java_path'
      IF LENGTH( java_path ) < 2 THEN DO
         PARSE UPPER VALUE rxFind( 'JAVA.EXE', ' -version', 'VERSION "1.' ) WITH java_path'\BIN'
         IF LENGTH( java_path ) = 0 THEN
         DO
            CALL LINEOUT 'STDERR', 'JAVA engine not found'
            RETURN 1
         END
         CALL SysPutEA this, 'JAVA_PATH', java_path
      END
     
      CALL SysGetEA this, 'NETRX_PATH', 'netrx_path'
      IF LENGTH( netrx_path ) < 2 THEN DO
         PARSE UPPER VALUE rxFind( 'NetRexxC.jar' ) WITH netrx_path'\LIB'
         IF LENGTH( netrx_path ) = 0 THEN
         DO
            CALL LINEOUT 'STDERR', 'NetRexx not found'
            RETURN 2
         END
         CALL SysPutEA this, 'NETRX_PATH', netrx_path
      END
      objID = 'NRXC'
      netrx_name = 'NetRexxKing'
      IF wpsObjectExist( '<WP_'objID'>' ) = 0 THEN
      DO
         setupstring = 'OBJECTID=<WP_'objID'>;EXENAME='this';PARAMETERS=[Type "-run" (without quotes) to run compiled script] %**P\%**F;ASSOCFILTER=*.nrx;ICONFILE='netrx_path'\'netrx_name'.ico;'
         IF SysCreateObject( 'WPProgram', 'NetRexx Compiler / Run', '<WP_DEVFLDR>', setupstring, 'U' ) <> 1 THEN
            CALL SysCreateObject 'WPProgram', 'NetRexx Compiler / Run', '<WP_DESKTOP>', setupstring, 'U'
         CALL rxAddBigIcon netrx_path'\'netrx_name'.png', '<WP_'objID'>'
      END
      IF netrx.noc THEN
         CALL VALUE 'PATH', VALUE( 'PATH',, env )'.;'java_path'\bin;'java_path'\lib;'netrx_path'\runlib', env
      ELSE
         CALL VALUE 'PATH', VALUE( 'PATH',, env )'.;'java_path'\bin;'java_path'\lib;'netrx_path'\lib', env

      DO WHILE QUEUED() > 0
         PARSE PULL
      END
     
      /* Add option -norestart for OS/2s 1.0.2+ java.exe, for better display */
      old_trace = TRACE( 'O' )
      '@JAVA -version 2>&1|RXQUEUE'
      CALL TRACE old_trace
      PARSE PULL '1.' JVer ' '
      PARSE VALUE JVer WITH JVer'_'.
      javaopts = ''
      IF JVer >= 6.0 THEN
         CALL VALUE 'CLASSPATH', netrx_path'\lib\NetRexxF.jar;'netrx_path'\lib\NetRexxC.jar;', env
      ELSE IF JVer >= 0.2 THEN javaopts = '-norestart'
      ELSE javaopts = '-noasyncgc'
     
      /* Add any options from NETREXX_JAVA environment variable */
      javaopts = javaopts VALUE( 'NETREXX_JAVA',, env )
   END
   OTHERWISE
   /* Add any options from NETREXX_JAVA environment variable */
   javaopts = VALUE( 'NETREXX_JAVA',, 'ENVIRONMENT' )
END

CALL rxARGs

'@JAVA -version'
IF netrx.noc THEN
   '@JAVA ' javaopts '-jar 'netrx_path'\lib\NetRexxF.jar -exec' args
ELSE
DO
   CALL LINEOUT 'STDERR', 'Compiling...'
   '@JAVA ' javaopts 'org.netrexx.process.NetRexxC' STRIP( iargs filec )
END   

IF ( rc <= 1 & netrx.run ) | ( netrx.noc & rc <> 0 ) THEN
DO
   CALL rxARGs
   DO WHILE LENGTH( files ) > 0
      PARSE VALUE files WITH f_name'.class' files
      CALL LINEOUT 'STDERR', 'Running' f_name '...'
      '@JAVA 'f_name
      IF rc <> 0 THEN PARSE PULL
   END
END
CALL DIRECTORY old_dir
RETURN rc

rxARGs:
   inargs = args
   iargs = ''
   files = ''
   filec = ''
   DO FOREVER
      PARSE VAR inargs file inargs
      IF file = '' THEN LEAVE
      IF LEFT( file, 1 ) = '-' THEN
      DO
         iargs = iargs file
         ITERATE
      END
      dir = DIRECTORY( file )
      IF POS( '*', file ) > 0 | STREAM( file, 'C', 'QUERY EXISTS' ) <> '' | dir <> ''  THEN
      DO
         IF dir <> '' THEN
            file = file'\*.nrx'
         CALL SysFileTree file, 'filename.', 'FO'
         DO i = 1 TO filename.0
            filec = filec filename.i
            PARSE VALUE REVERSE( filename.i ) WITH ext'.'fname'\'path
            fname = REVERSE( fname )
            IF STREAM( fname'.class','C', 'QUERY EXISTS' ) <> '' THEN
            DO
               files = STRIP( files fname'.class' )
               CALL DIRECTORY path
            END
         END
      END
   END
RETURN

rxChk: PROCEDURE
   DO WHILE QUEUED() > 0; PARSE PULL; END;
   '@'||ARG(1)||ARG(2)||' 2>>&1 | RXQUEUE'
   DO WHILE QUEUED() > 0
      IF POS( TRANSLATE( ARG(3) ), TRANSLATE( LINEIN( 'QUEUE:' ) ) ) > 0 THEN
         IF LENGTH( ARG(4) ) > 0 THEN RETURN ARG(4)
   END
RETURN ''

rxFind: PROCEDURE EXPOSE !_msg_!.
   PARSE VALUE REVERSE( SysSearchPath( 'PATH', ARG(1) ) ) WITH .'\'fpath
   fpath = REVERSE( fpath )
   IF ARG() > 1 & LENGTH( fpath ) > 0 THEN
      fspec = rxChk( fpath'\'ARG(1), ARG(2), ARG(3), fpath )
   ELSE IF STREAM( fpath'\'ARG(1), 'C', 'QUERY EXISTS' ) <> '' THEN
      fspec = fpath
   ELSE fspec = ''
   IF LENGTH( fspec ) > 0 THEN RETURN fspec
   CALL LINEOUT 'STDERR', VALUE( 'PROGRAMS',,'OS2ENVIRONMENT' )
   CALL SysFileTree VALUE( 'PROGRAMS',,'OS2ENVIRONMENT' )||'\*'||ARG(1), 'file.', 'SFO'
   DO i = 1 TO file.0
      PARSE VALUE REVERSE( file.i ) WITH .'\'fspec
      IF ARG() > 1 THEN
         fspec = rxChk( file.i, ARG(2), ARG(3), REVERSE( fspec ) )
      ELSE
         fspec = REVERSE( fspec )
      IF LENGTH( fspec ) > 0 THEN RETURN fspec
   END
   drives = SysDriveMap( 'C:', 'USED' )
   DO j = 1 TO WORDS( drives )
      CALL LINEOUT 'STDERR', SUBWORD( drives, j, 1 )
      CALL SysFileTree SUBWORD( drives, j, 1 )||'\*'||ARG(1), 'file.', 'SFO'
      DO i = 1 TO file.0
         PARSE VALUE REVERSE( file.i ) WITH .'\'fspec
         IF ARG() > 1 THEN
            fspec = rxChk( file.i, ARG(2), ARG(3), REVERSE( fspec ) )
         ELSE
            fspec = REVERSE( fspec )
         IF LENGTH( fspec ) > 0 THEN RETURN fspec
      END
   END
RETURN ''
   
rxAddBigIcon: PROCEDURE EXPOSE !_msg_!. java_path
    crlf = D2C(13)D2C(10)
    bigicons_dir = VALUE( 'BIGICONS',, 'OS2ENVIRONMENT' )
    bigicon = FILESPEC( 'N', ARG(1) )
    objid = ARG(2)
    IF LENGTH( bigicons_dir ) > 0 THEN
    DO
        IF STREAM( ( bigicons_dir'\'bigicon ), 'C','QUERY EXISTS') = '' THEN
           IF SysCopyObject( ARG(1), bigicons_dir ) = 0 THEN
              RETURN 1
        IF STREAM( bigicons_dir'\bigicons.txt', 'C', 'QUERY EXIST' ) <> '' THEN
        DO
            f_size = STREAM( bigicons_dir'\bigicons.txt', 'C', 'QUERY SIZE' )
            IF f_size > 0 THEN
            DO
                input = CHARIN( bigicons_dir'\bigicons.txt', 1, f_size )
                CALL STREAM bigicons_dir'\bigicons.txt', 'C', 'CLOSE'
                PARSE UPPER VALUE input WITH pre'"'(bigicon)'"'post
                IF LENGTH( post ) > 0 THEN RETURN 2
                PARSE UPPER VALUE input WITH pre'"'(objid)'"'post
                IF LENGTH( post ) > 0 THEN RETURN 3
                PARSE VALUE input WITH pre'[OBJECTID]'mid(crlf)(crlf)'['post
                input = pre'[OBJECTID]'STRIP( STRIP( mid, 'T', D2C(10) ), 'T', D2C(13) )||crlf||LEFT( '"'objid'"', 28 )'"'bigicon'"'crlf||crlf'['post
                CALL SysFileDelete bigicons_dir'\bigicons.txt'
                CALL CHAROUT bigicons_dir'\bigicons.txt', input
                CALL STREAM bigicons_dir'\bigicons.txt', 'C', 'CLOSE'
            END
            ELSE RETURN 4
        END
    END
RETURN 0

/* Code borrowed from REXX Tips & Tricks v3.60 */
wpsObjectExist: PROCEDURE /* parameter: '<new_wps_object_id>', return: 1 exist, 0 doesn't exist, 43 error */
  PARSE ARG objID
  rc = 43               /* init return/error code 43 = routine not found */
  SIGNAL ON SYNTAX NAME ObjectExistError

  IF SUBSTR( objID, 2, 1 ) <> ":" THEN
      IF LEFT( objID, 1 ) <> "<" & RIGHT( objID, 1 ) <> ">" THEN
          objID = "<" || objID || ">"

  /* create the object and see if it fail */
  tempRC = SysCreateObject( "WPFolder", "TestObject", "<WP_NOWHERE>", "OBJECTID=" || objID || ";", "FAIL" )

  IF tempRC = 1 THEN
  DO
    CALL SysDestroyObject objID
    rc = 0
  END
  ELSE
    rc = 1

ObjectExistError:

RETURN rc

6
Applications / XWorkplace enhancements
« on: August 04, 2016, 05:50:49 pm »
Hello,

Would like to ask for a feature enhancement to XWorkplace, "large icon support" (such as 32x32 and 40x40 pixels) in XCenter, but can't register nor add it to the new tracker.

Regards
//Jan-Erik Lärka

7
Applications / OpenOffice Base and ODBC
« on: January 10, 2016, 02:32:51 pm »
The read1st.txt state:
Quote
- Base module supports dBase, MySQL, ODBC databases.
  HSQLDB not tested (requires Java).
I've used OpenOffice 3.2 with PostgreSQL 8.x (now 9.x) on eCS but had to patch odbc.dll in unixODBC 0.10.
I can't make it work with Apache OpenOffice 4.1.2 (nor 4.1.1).
I can connect with ODBC

Does Apache OpenOffice need something more/else?

8
Programming / Desktop Weather
« on: September 01, 2015, 08:29:04 pm »
Hello,

I've created a rexx script that should show you the current weather.
It has been designed to be used with PNG Desktop as it update the image (icon) and desktop text to describe the current weather and temperature.

The script download png images from the net and use a Smart Guide to guide you through different possible settings you may tweak.

Please do note that you shouldn't make to drastic changes nor to many images (icon) on the desktop as it should be rewritten to handle such situations better. Stop the script in the startup folder and restart it to update the desktop image icon right away. The program object in the startup folder handle updates and you have to delete it by hand if you want to get rid of the desktop image (icon) as well or it will try to recreate it all over again.  ;)

9
Applications / QT frontend to unixodbc
« on: August 28, 2015, 11:00:32 pm »
Where can one ask if someone can build a QT app?

unixodbc (http://www.unixodbc.org/) has been separated into the "engine" and the "driver manager" where the later use QT4 as gui. The engine has been ported to OS/2 - eCS, but where do we ask for someone to build the qt4 gui for it?

//Jan-Erik

10
General Discussion / Open Source / 2
« on: July 07, 2015, 01:31:14 pm »
Hello,

the open source movement is strong and we that use OS/2 and eComStation benefit from several projects that originate or build on open source projects. Martin has done a great job to open source software and collecting sources.

What's the plan and how do we make best use of the source code?! Source code doesn't compile itself, someone has to do it and get a project afloat?

Regards,
//Jan-Erik

11
Programming / Google KML/KMZ to CSV
« on: June 12, 2015, 07:37:55 pm »
Hello,

I've been busy writing scripts that help me extract information from Google Maps.

Here's a script that does the opposite, it take a Google Map KML/KMZ file and convert the information into a csv file that can be used within Lotus 123, OpenOffice Calc etc.

It basically tries to unzip the file if it's a .kmz-file and read and interpret the xml-file into something usable. (See attachment if you're logged on)

Parameter: filename.kml or filename.kmz
Additional parameter: output.txt or something that can be used as output with tab separated values
Defaults to Standard Out on screen
Extra parameter: Tag such as "body" to limit the input between that tag but it only work when the environment variable fiberkartan has been set to 1.

//Jan-Erik

12
Applications / jEdit 5.1.0 filebrowser
« on: January 24, 2015, 11:06:12 am »
Hello,

it's impossible to open and/or save files in jEdit 5.1.0

I suspect that the trailing backslash is the cause of the problem, something that is not allowed in OS/2.
The file browser doesn't list anything and just append the path over and over again, with a trailing backslash.

How can this be fixed, or better yet, get jEdit the developers to rewrite the code to remove trailing backslashes altogether.

//Jan-Erik

13
Mail-News / Send email from commandline (actually a rexx script)
« on: December 13, 2014, 01:20:55 pm »
Hello,

What tool is available to send emails from command line?

I've created a quite large script that at the end has to reply to 12 e-mail addresses.
The text in the body has to contain national characters such as å, ä and ö and a png image (each different) as attachement.

1. PMMail run a filter that detect a certain file from a certain sender
2. PMMail launch my rexx script
3. My rexx script use a python script to convert the xlsx-file into a csv-file
4. My rexx script interpret the file and get the coordinates of addresses from google (maps api) specified in the csv-file
5. My rexx script write 1 + 4 × 10 different files based on areas, contacting info, misspelled addresses etc.
6. My rexx script start an OpenOffice .ods file that use a series of macros to (among other things) export 12 charts to a ftp-server through netdrive.
7. My rexx script should send an email to give a brief update and notify each person about the current status and attach a chart (png image) exported from the .ods-file by the macros to show how far they've come.

Suggestions?

No, PMMSend remove å, ä and ö, so it has to be fixed first.
Yes, they fixed the = ? encoding problem yesterday.

Ohh, yes, I need the solution up and running by tomorrow (Sunday 14 December 2014)  :P

Regards,
//Jan-Erik

14
Programming / Rexx script to enable OpenOffice Macro support!
« on: April 16, 2014, 11:28:30 pm »
Hello,

I've used OpenOffice.org for quite some time and consider myself as a power user when it come to designing spreadsheets, so the disabled support for macros in OpenOffice.org has been annoying to say the least

I today found the relevant post how to enable marco security and now written a rexx script and tested it successfully. You can test and use it as well!

You need a macro in your spreadsheet to see that it actually work, so follow the steps below to add the relevant but very simple code to your spreadsheet

Regards,
//Jan-Erik

OpenOffice.org Calc
Menu:Tools -> Macros -> Organize macros -> OpenOffice.org Basic...
Window:OpenOffice.org Basic Macros
Area:Macro from
Treeview:[-]<Select your spreadsheet>
Mark:[-] Standard
Button:[  New  ]
Window:New Module
Field:Name:
Keyboard:GetSheetName
Button:[  OK  ]
Window:<Your spreadsheets name> - OpenOffice.org Basic
Cut & Paste:
Code: [Select]
Function GetSheetName( i )
On Error Goto trap
GetSheetName = ThisComponent.Sheets(i-1).Name
Exit Function
trap:
GetSheetName = erl()
End Function
Menu:File -> Save
Menu:File -> Close
Spreadsheet:Select a cell
Keyboard:=getsheetname(3)
Keyboard:Enter
As you press enter the cell will show #VALUE
Save the spreadsheet and run the script below and set it to 1
Higher value mean higher security but also more restrictions
Reopen the spreadsheet
Allow it to run the macro
You should now see the name of the third tab in your spreadsheet in the cell.
====

You will see a window that ask if you want to enable macros if you set the security level to 1.
You can rerun this script if you like to increase or decrease the security level.
Code: [Select]
/*
 * Filename: OOorgMacro.cmd
 *   Author: JAN-ERIK
 *  Created: Wed Apr 16 2014
 *  Purpose: Add macro security tag to configuration file to be able to run Macros in the OS/2 and eComstaiton version of OpenOffice.org
 *  Changes:
 */

/* Load RexxUtil Library */
IF RxFuncQuery('SysLoadFuncs') THEN
DO
    CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
    CALL SysLoadFuncs
END
CALL SysCls
CALL LINEOUT 'STDERR', 'OpenOffice.org for OS/2 and eComstation'
CALL LINEOUT 'STDERR', "doesn't contain a utility to allow you to enable macros"
CALL LINEOUT 'STDERR', ''
CALL LINEOUT 'STDERR', 'This script will attempt to enable macro security for you.'
CALL LINEOUT 'STDERR', ''
CALL LINEOUT 'STDERR', 'Please do note that you should be aware that macros may'
CALL LINEOUT 'STDERR', "be harmful so don't open files from unknown sources or"
CALL LINEOUT 'STDERR', 'files that may contain macros.'
CALL LINEOUT 'STDERR', ''
CALL LINEOUT 'STDERR', "Don't blame the author of this script for any harm caused!"
CALL LINEOUT 'STDERR', ''
CALL CHAROUT 'STDERR', 'Do you want to continue (yes/No)? (N by default) '
PARSE PULL answer
IF TRANSLATE( LEFT( answer, 1 ) ) <> 'Y' THEN RETURN 0
level = ' '
DO WHILE \DATATYPE( level, 'W' )
    CALL LINEOUT 'STDERR', ''
    CALL LINEOUT 'STDERR', 'Valid values are: 0 - the lowest; 1 - the lower; 2 - default; 3 - the highest'
    CALL LINEOUT 'STDERR', ''
    CALL CHAROUT 'STDERR', 'Specify the security level to use (4 and above to abort): '
    PARSE PULL level
    IF level = '' THEN level = 2
    IF level < 0 THEN level = ' '
    IF level > 3 THEN RETURN level
END

newln = D2C(10)
add.1 = '<node oor:name="Security">'
add.2 = '  <node oor:name="Scripting">'
add.3 = '   <prop oor:name="MacroSecurityLevel" oor:type="xs:int">'
add.4 = '    <value>'||level||'</value>'
add.5 = '   </prop>'
add.6 = '  </node>'
add.7 = '</node>'
add.8 = '</oor:component-data>'
add.0 = 8

CALL CHAROUT 'STDERR', '.'
home_dir = VALUE( 'HOME',, 'OS2ENVIRONMENT' )

IF SysFileTree( home_dir||'\*common.xcu', 'file.', 'SFO' ) = 0 THEN
DO i = 1 TO file.0
    f_size = STREAM( file.i, 'C', 'QUERY SIZE' )
    IF f_size = 0 THEN ITERATE
    input = CHARIN( file.i, 1, f_size )
    CALL STREAM file.i, 'C', 'CLOSE'
    PARSE VALUE input WITH pre(add.8).
    PARSE VALUE pre WITH pre(add.1).
    DO j = 1 TO add.0
        CALL CHAROUT 'STDERR', '.'
        pre = pre||add.j
        IF j < add.0 THEN
            pre = pre||newln
    END
    IF SysFileDelete( file.i ) = 0 THEN
        CALL CHAROUT file.i, pre
    CALL CHAROUT 'STDERR', '.'
END

15
Programming / Schedule Wake Up with DragText 3.x
« on: February 06, 2014, 03:51:35 pm »
Hello,

I use my computer to wake me up in the morning.

The excellent DragText 3.9 add convenient drag & drop functions that I sometime forget is not present elsewhere when I have to use other systems. DragText also contain a scheduler and the documentation is straight forward and mention how to set the variables, but I can't find a way to complete the setup with the script as the text for REPEAT puzzle me a bit.

"REPEAT = ON | OFF
Set the object to reopen on a regular basis. The year must have 4 digits; the month and day must have 2."

The only possible settings for REPEAT is therefore ON or OFF.

How do I set the repeat interval with the information above, or...?



The code below should create Program objects in your Utilities folder that point to a script called AxelF.cmd placed in the same folder as this script. Day, date and start time will be set, but it can't quite yet complete the setup unless you set the interval by hand and activate each scheduled Program Object.

//Jan-Erik
Code: [Select]
/*
 * Filename: wakeup.cmd
 *   Author: JAN-ERIK
 *  Created: Sun Jan 26 2014
 *  Purpose: Script to create schedule of wake up tunes.
 *  Changes:
 */

/* Load RexxUtil Library */
IF RxFuncQuery( 'SysLoadFuncs' ) THEN
DO
    CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
    CALL SysLoadFuncs
END

folder = '<WP_TOOLS>'
prefix = 'Alarm '
app = DIRECTORY()||'\AxelF.cmd'

day.1 = 'MONDAY'
day.2 = 'TUESDAY'
day.3 = 'WEDNESDAY'
day.4 = 'THURSDAY'
day.5 = 'FRIDAY'
day.6 = 'SATURDAY'
day.7 = 'SUNDAY'
day.0 = 7

/* Set the wake up Time */
day.1.t = '06:00:00'
day.2.t = '05:10:00'
day.3.t = '06:00:00'
day.4.t = '05:10:00'
day.5.t = '06:00:00'
day.6.t = '08:00:00'
day.7.t = '08:00:00'

/* Translate to your own language */
day.1.n = 'Monday'
day.2.n = 'Tuesday'
day.3.n = 'Wednesday'
day.4.n = 'Thursday'
day.5.n = 'Friday'
day.6.n = 'Saturday'
day.7.n = 'Sunday'

today = TRANSLATE( DATE( 'W' ) )
PARSE VALUE DATE( 'S' ) WITH yyyy +4 mm +2 dd
DO i = 1 TO day.0
    IF today = day.i THEN LEAVE
END
IF i < 7 THEN
DO j = i + 1 TO day.0
    CALL CreateSchedule prefix||day.j.n, folder, 'EXENAME='||app||';OBJECTID=<ALARM_'||day.j||'>;SCHEDULE=ON;DATE='||Unbase( CalcBaseDate( DATE( 'S' ) ) + j )||';TIME='||day.j.t||';REPEAT=ON;ALWAYSOPEN=ON;'
    CALL SysSleep 1
END
IF i > 2 THEN
DO j = 1 TO i
    CALL CreateSchedule prefix||day.j.n, folder, 'EXENAME='||app||';OBJECTID=<ALARM_'||day.j||'>;SCHEDULE=ON;DATE='||Unbase( CalcBaseDate( DATE( 'S' ) ) + j )||';TIME='||day.j.t||';REPEAT=ON;ALWAYSOPEN=ON;'
    CALL SysSleep 1
END
RETURN 0

CreateSchedule: PROCEDURE
/* Remove or Comment out the next line when the code has been completed */
    SAY ARG(3)
    IF SysCreateObject( 'WPProgram', ARG(1), ARG(2), ARG(3), 'U' ) THEN
        SAY '"'||ARG(1)||'" has been created'
    ELSE SAY "Couldn't create "||'"'||ARG(1)||'"'
RETURN 0

DATED: PROCEDURE
    PARSE VALUE DATE( 'S' ) WITH yyyy +4 mm +2 dd
    today = DATE( 'D' )

RETURN 0
PARSE VALUE DATE( 'S' ) WITH yyyy +4 mm +2 dd

UnBase: Procedure
    PARSE ARG x
    If x > 3652058 then Return 'BAD'
    /*  Numeric digits 14 */
    opy = 400  * ( x + 1 ) % 146097
    ddd = x + 1 - ( opy * 365 + opy % 4 - opy % 100 + opy % 400 )
    If ddd = 366 then
    Do
        NLeapYear = ( ( ( opy + 1 ) // 4 ) <> 0 )
        opy = opy + NLeapYear
        If NLeapYear then ddd = 1
    End
    If ddd = 0 then
    Do
        LeapYear = opy // 400 = 0 | ( opy // 4 = 0 & opy // 100 <> 0 )
        ddd = 365 + LeapYear
        opy = opy - 1
    End
Return ISODate( right( opy + 1, 4, 0 ) || right( ddd, 3, 0 ) )

Syntax:
    say 'At line' sigl':' errortext(rc)
Return 'BAD'

ISODate: Procedure
    Parse arg yyyy 5 ddd .
    LeapYear = yyyy // 400 = 0 | ( yyyy // 4 = 0 & yyyy // 100 <> 0 )
    If ddd > 59 + LeapYear then y = 2 - LeapYear
    Else y = 0
    z = ddd + y + 91
    m = (z * 100 ) % 3055
    d = z - ( m * 3055 ) % 100
Return yyyy'/'right( m - 2, 2, 0 )'/'right( d, 2, 0 )

CalcBaseDate: PROCEDURE
  NonLeap.   = 31
  NonLeap.0  = 12
  NonLeap.2  = 28
  NonLeap.4  = 30
  NonLeap.6  = 30
  NonLeap.9  = 30
  NonLeap.11 = 30

  parse arg cyear +4 cmonth +2 cdate

  if length( cyear ) <= 2 then
    if cyear < 80 then
      fullyear = "20" || cyear
    else
      fullyear = "19" || cyear
  else
    fullyear = cyear

  numyears = fullyear -1
  basedays = numyears * 365
  QuadCentury = numyears % 400
  Century = numyears % 100
  LeapYears = numyears % 4
  basedays = basedays + (((LeapYears - Century) + QuadCentury) - 1)

  do i = 1 to (cmonth -1)
    if i <> "2" then
      basedays = basedays + NonLeap.i
    else /* find if it's a leap year or not */
      if (fullyear // 4) > 0 then
        basedays=basedays + 28
      else
        if ((fullyear // 100) = 0) & ((fullyear // 400) > 0) then
        do
                        /* century not divisble by 400                */
          basedays = basedays + 28
        end /* if */
        else
        do
                        /* quad century or regular leap year          */
          basedays = basedays + 29
        end /* else */
  end /* do */

  basedays = basedays + cdate
return basedays

Pages: [1] 2