wss + time commands family by Sessai@NIPR, 1999

A new QNX command, 'wss' is a replacement of 'ws' command in old QNX4.22
which had some bugs.
This 'wss' can work around year 2000, even up to year 2100 I believe...
(It's OK at least up to 2038/ 1/19 03:14:07 UTC
 which is the upper limit of (signed long integer) 32-bits Unix time...
 but most commands will also be OK upto year 2100...)
and many (probably) useful commands related to time handling are also available.
Enjoy...

to install...
get
	wss-1.02.tar.gz onto your QNX machine
and do
	install -u wss-1.02.tar.gz
(You can choose install directory (default is /usr/local/bin).)


wss		: replacement of old "ws" command in QNX 4.22

	"find" command has "-mtime" option
	which is true when file modification time subtracted from the
	initialization time is n-1 to n multiples of 24 hours
	but only very rough 24 hours boundary...
	find can NOT find(choose),  say, files which was modified between
	12:00 UT yesterday and 0:30 UT today.
	"wss" command can easily achieve it as follows
		wss -a `yesterday` 12 0 0 -b `today` 0 30 0 [. ["echo @"]]

	you can see the usage of this "wss" below in this page to see more info!

ftime		: show file modification/access/change status/creation time

ymdhmsnow	: print YYYY MM DD hh mm ss now
    ymdnow	: print YYYY MM DD today
    hmsnow	: print hh mm ss now
    today	: = ymdnow
    ymdh2hB	: print YYYYMMDDhh (hh is int([hour now]/2)*2)
	(These 4 commands are just symlinks of ymdhmsnow)
    (ymshmsnow is very powerful and has many options!!!!!!
	you can show, e.g. time, 3 years 5 months 7 days 9 hours 11 min 13 secs
	before 2035/12/23 15:58:23 (any given time) as follows
		ymdhmsnow -e 2035 12 23 15 58 23 -Y 3 -M 5 -D 7 -h 9 -m 11 -s 13
     do 'use ymdhmsnow' to know more info!!!!)
yesterday	: print yesterday's YYYY MM DD
tomorrow	: print tomorrow's YYYY MM DD
utnow		: print unix time now
utnow2		: print unix time now including minor time
    ut2now	: = utnow2
wdnow		: print weekday today
ydnow		: print yearday today
    tdnow	: = ydnow
ysnow		: print yearsecond now

ut2ymdhms	: convert unix time to YYYY MM DD hh mm ss
    ut2ymdhmsc	: convert unix time to YYYYMMDD hhmmss
    ut2ymdhmsC	: convert unix time to YYYYMMDDhhmmss
    ut2ymd	: convert unix time to YYYY MM DD hh mm ss and show only YYYY MM DD
    ut2ymdc	: convert unix time to YYYY MM DD hh mm ss and show only YYYYMMDD
    ut2hms	: convert unix time to YYYY MM DD hh mm ss and show only hh mm ss
    ut2hmsc	: convert unix time to YYYY MM DD hh mm ss and show only hhmmss
	(These 6 commands are just symlinks of ut2ymdhms)
ut2yys		: convert unix time to year and yearsecond
ymd2wd		: convert YYYY MM DD to weekday
    wday	: = ymd2wd
ymd2yd		: convert YYYY MM DD to yearday
    yday	: = ymd2yd
    tday	: = ymd2yd
ymdhms2ut	: convert YYYY MM DD hh mm ss to unix time
    ut		: = ymdhms2ut
ymdhms2ys	: convert YYYY MM DD hh mm ss to yearsecond
    ysec	: = ymdhms2ys
yyd2ymd		: convert year and yearday to YYYY MM DD
    yd2md	: = yyd2ymd
yys2ut		: convert year and yearsecond to unix time
yys2ymdhms	: convert year and yearsecond to YYYY MM DD hh mm ss

D,DD,DDD,DDDD - show current time (including minor time)
	D	: show current time on this QNX node
	DD	: show current time on all alive QNX nodes
	DDD	: show current time on all alive QNX nodes
	DDDD	: show current time on all alive QNX nodes and additional info
date2		: show current time on all alive QNX nodes
now		: same as ymdhmsnow (use date command)
nowc		: same as utnow	(use date and ymdhms2ut commands)
u2ut		: convert unix time to YYYY MM DD hh mm ss(=ut2ymdhms)
ut2u		: convert YYYY MM DD hh mm ss to unix time(=ymdhms2ut)

node		: print node number of this QNX node
osinfo		: print QNX OS info
osclock		: print QNX OS info and time on all alive nodes

	use 'use' command to know more detail info!!

Usage of 'wss' command (output of 'use wss') wss - do something strange... as a replacement of the old buggy "ws" command in QNX422 by Sessai@NIPR in 1999 wss [-v|-vv] [-w|-ww|-www] [-f|-F|-d|-D|-L|-S] [-r] [-a YYYY MM DD hh mm ss] [-b YYYY MM DD hh mm ss] [dir [cmd]] -v : show each file name before executing command -vv : show each file info before executing command "ws dir" = "ws -v dir" = "ls -1 dir" "ws -vv dir" is similar to "ls -laF dir" the file info format is YYYY/MM/DD hh:mm:ss TMode n u/g size name[c [-> lname[c]]] MTime TypeMode Nlink Uid/Gid Size Name Type : - : regular file (8) d : directory (4) l : symlink (A) b : block special device file (6) c : character special device file (2) n : FIFO/Socket/SpecialNamedFile (1/C/5) X : unknown(=(stat.st_mode&0F0000)>>12) code : / : directory @ : symlink # : FIFO/Socket/SpecialNamedFile ??: unknown -w : show command error code if non zero (error will be put in stderr.) -ww : show command string and command error code if non zero (command string will be put in stdout) -www : show what -ww shows and more info (more info will also be put in stdout) -f : invoke command only to regular files (excluding symlinks!!) (do nothing to any directories, symlinks, special files etc.) -F : invoke command only to regular files including symlink files! (do nothing to any directories, special files etc.) (but do action for a symlink file even if it points to dir.) -d : invoke command only to directories (NOT including symlink!) ("." and ".." will always be skipped!!!) (do nothing to any regular files, links, special files etc.) -D : invole command only to any files except directories (do action for a symlink file even if it points to dir.) (try to do action also for any special files.) (This was the default behavior of old "ws" command.) -L : only symlink files will be processed. Others will just be skipped. -S : only special files will be processed. Others will just be skipped. * if neither -f,-F nor -d,-D,-L,-S specified, all files except "." and ".." will be processed! -r : Pass relative paths(only file name (not include dir name) to commands (even if DIR is an absolute path(dir) name). (if DIR is an absolute path (starting with '/'), @ char in cmd string will be replaced by abs_path by default. but -r specified, rel_path(only filename) will be passed. if DIR is a relative path, no effect. chdir(DIR) is always done before each command will be invoked.) DIR is AbsPath and -r not specified: chdir(DIR) and @ will be replaced by AbsolutePathName DIR is AbsPath and -r specified: chdir(DIR) and @ will be replaced by filename(no dir) DIR is RelPath and -r not specified: chdir(DIR) and @ will be replaced by filename(no dir) DIR is RelPath and -r specified: chdir(DIR) and @ will be replaced by filename(no dir) -a ... : invoke command only to files whose mtime are "equal or after" specified time -b ... : invoke command only to files whose mtime are "before" specified time dir : directory where this program will apply if omitted, "." will be assumed. BUT you MUST specify this if you specify command below!!! cmd : command string which will operate to each file '@' character will be replaced by each file name. if omitted, "echo @" will be assumed. (but if -v or -vv specified, NULL string will be assumed.) quotation marks are required for strings including spaces YYYY : year : This must be a 4 digit year!!!! MM : month DD : day hh : hour mm : minute ss : second [-v|-vv] [-w|-ww|-www] [-f|-F|-d|-D|-L|-S] [-r] [-a ..] [-b ..] [dir [cmd]] MUST be ordered like this!!! * "." and ".." will always be skipped. * output is not sorted (like original ws)!!! * no recursive operation so far!!! (sorry for no flexibility!) * "wss" = "wss ." = "wss . "echo @"" = "wss -v" ="ls -1" * "wss -vv" is similar to "ls -laF" Example1 (under /bin/ksh) ws -a DD/MM/YY hh:mm:ss -b "DD/MM/YY hh:mm:ss" -q DIR "cp -p @ DIR2" is equivalent to wss -D -a YYYY MM DD hh mm ss -b YYYY MM DD hh mm ss DIR "cp -p @ DIR2" Example2 (under /bin/ksh) ws -a "DD/MM/YY hh:mm:ss" -q -r DIR "echo @" is equivalent to wss -D -r -a "DD/MM/YY hh:mm:ss" DIR ["echo @"] Example3 ws -d -q -r DIR "ls -laFd @" is equivalent to wss -d -r DIR "ls -laFd @" Example4 show files which were modified yesterday under current directory (but not recursively) (and sort in time order...) wss [-r] -vv `yesterday` 0 0 0 -b `today` 0 0 0 . | sort Example5 show only regular files which were modified these 3 hours in ./ dir wss [-r] -f -a $(ymdhmsnow -h 3) -b `ymdhmsnow` [. ["echo @"]] Example6 print file list in current directory wss Example7 show all files' info in detail in DIR directory wss -vv DIR
cf: Usage of old 'ws' command (output of 'use ws' in QNX4.22) ws - walk directory structure executing a command (QNX) *** Note - it is recommended that you use the find utility *** instead of ws. ws [options]... [[directory] "command"] Options: -a date/time Use only files after date/time. -b date/time Use only files before date/time. -c [p=c|d=c] Set path/delete char to character c or \\octal. -d Exec on directories, not files. -e ignore|prompt|abort On an error; ignore, prompt or abort. -g group[,group]* Use only files belonging to these groups. -l levels Recurse this number of levels. -m mode[,mode]* Use only on files matching these modes. -[Pp] pattern[,pattern]* All files exec'ed on must match this pattern. -q Quiet. Don't display commands executed. -i Interactive. Query user before executing each invocation of 'command'. -r Pass relative paths to commands. -t Ignore the date/time of files being processed. -u owner[,owner]* Exec on files belonging to these users. Where: Date/time format is "[UTC] day/month/yr hr:min:sec", 24 hr clock. Mode format is octal or <[u|g|o]...|a>=[r|w|s]... Modes and patterns may be preceded by '!' meaning 'not'.
Sessai

-------------------------------------------------------------------------------
From Sessai Sat Dec 11 01:08:30 1999
Date: Sat, 11 Dec 99 01:08:25 JST
To: darn-qnx
Subject: y2k compliant 'ws' -- wss
Cc: SD Kikuchi

Hello,

Just a small announcement...

I imagine most of QNX users have not used an old "ws" command,
but if some of you are still using it and need to overcome y2k,
this might help..

Some of you might have still been using 'ws' command in old QNX4.22
which can run even on QNX 4.25B but which is not included in QNX OS >=4.23.
The 'ws' command was not y2k compliant
(but we can set year=100,101,... for year 2000,2001,2002,... actually...).
'find' command was recommended instead by QSSL.
But if we want to pick up only files. say. which was modified
before 2 hours ago, or which was modified before 00:15 UT today,
or, say, if we want to pick up only files which was modified
during particular time period which is not multiple of 24 hours,
it's difficult for 'find' command to deal with,
and 'ws' can much more easily achieve these kind of staff.

I created a new QNX command, 'wss' which is a replacement of
the old 'ws' command in old QNX4.22 (originally just for my purpose).
This 'wss' can work around year 2000, even up to year 2100 I believe...
(It's OK at least up to 2038/ 1/19 03:14:07 UTC
 which is the upper limit of (signed long integer) 32-bits Unix time...
 but most commands included in the package below will also be OK up to
 year 2100...)
(But this wss does not handle pattarn matching yet because I don't need it.)

Many (probably) useful commands related to time handling
are also included in this package.

We were  using 'ws' command at Syowa for moving data
from Radops PCs at radar site to other PCs which has MO drives at Syowa
and for sending them to NIPR every 2 hours.
I've tested this newer 'wss' these 2-3 months at Syowa without any problem.

If some of you want to use y2k compliant 'ws'-like command on your QNX box,
a package including the source codes is available on

	http://www.uap.nipr.ac.jp/SD/
	(and click "wss + time command family for Y2K overcome for QNX")

Regards,
Sessai

-------------------------------------------------------------------------------
From JTH Sat Dec 11 02:11:10 1999
Date: Fri, 10 Dec 1999 17:11:05 +0000
To: Sessai
From: Julian Thornhill
Subject: Re: y2k compliant 'ws' -- wss

At 16:21 10/12/99 +0000, you wrote:
>Hello,
>
>Just a small announcement...
>
>I imagine most of QNX users have not used an old "ws" command,
>but if some of you are still using it and need to overcome y2k,
>this might help..

What version of QNX was your ws supplied with? As you can see below, QNX 
think 4.21 and above should be ok.


The ws in versions prior to 4.20 links in the known bad
Watcom lib routines, as documented on our y2k web page.
I didn't know about a non-compliance in later ws utilities
before it had been dropped from the product.


Julian Thornhill

-------------------------------------------------------------------------------
From Sessai Sat Dec 11 02:32:13 1999
Date: Sat, 11 Dec 99 02:32:10 JST
To: JTH
Subject: Re: y2k compliant 'ws' -- wss
Cc: Sessai

Dear Julian,

Thanks for your message.

> >Hello,
> >
> >Just a small announcement...
> >
> >I imagine most of QNX users have not used an old "ws" command,
> >but if some of you are still using it and need to overcome y2k,
> >this might help..
> 
> What version of QNX was your ws supplied with? As you can see below, QNX 
> think 4.21 and above should be ok.
> 
> 
> The ws in versions prior to 4.20 links in the known bad
> Watcom lib routines, as documented on our y2k web page.
> I didn't know about a non-compliance in later ws utilities
> before it had been dropped from the product.

I'm not quite sure if I can understand what you meant.
I only supply its source code (and make file).
You can compile it on QNX 4.24/QNX4.25/QNX4.25A/QNX4.25B at least.

And ws command on QNX4.22A is not Y2K compliant.
When you want use option -a and/or -b,
year in 'date/time' part is 2 digit for year <2000.
And cannot deal with year >=2000 properly.
It can handle _ONLY_ few years(less than 10 years) after year 2000,
and even you can, you cannot use 4-digit year.
year=100 should be used for year 2000. year=101 for year 2001,
but it cannot be applied for, say, year 2010.

Does this make sense for your comment or not?

Regards,
Sessai

-------------------------------------------------------------------------------
From JTH Tue Dec 14 02:04:52 1999
Date: Mon, 13 Dec 1999 17:04:46 +0000
To: Sessai
From: Julian Thornhill
Subject: Fwd: Re: ws and y2k

The first message below is the latest news from QNX on ws. Could you let me 
have your comments please?

thanks

Julian



>Subject: Re: ws and y2k
>To: jth@ion.le.ac.uk (Julian Thornhill)
>Date: Mon, 13 Dec 1999 11:38:52 -0500 (EST)
>From: "Eric Johnson" 
>
>I've tested it briefly and haven't been able to make it
>fail with the Oct 28  1992 version available for free on QUICS.
>It doesn't support 2-digit years past 1999, but 4 digit years
>function correctly. I wasn't able to duplicate the 2010 failure -
>even using the undocumented '1xx' year format e.g.
>ws -a 'UTC 01/01/120' 'echo @' will show my Jan 2030 test file.
>If you could provide more detail I will be happy to investigate
>until I have an explanation for that.
>
>I have relinked a new 16-bit ws so that it will support 2-digit
>year windowing, and have posted that under /usr/free on QUICS
>(/usr/free/qnx4/os/utils/misc/ws). You will have to add back
>execute permission after downloading it.
>
>I would recommend that you change your scripts to use 4-digit
>years anyway - it is better practice.
>
>- Eric
>
>Julian Thornhill wrote:
> >
> > This is what I got from Japan:
> >
> > And ws command on QNX4.22A is not Y2K compliant.
> > When you want use option -a and/or -b,
> > year in 'date/time' part is 2 digit for year <2000.
> > And cannot deal with year >=2000 properly.
> > It can handle _ONLY_ few years(less than 10 years) after year 2000,
> > and even you can, you cannot use 4-digit year.
> > year=100 should be used for year 2000. year=101 for year 2001,
> > but it cannot be applied for, say, year 2010.
> >
> > ---------
> >
> > He is quite correct. The year can only be given as a two digit 
> quantity, as
> > the date format is dd/mm/yy. So if I were to use the -b option( which I
> > currently use in some scripts), I guess in 2000, giving the year as 00,
> > files created in 99 (1999) would not be detected as being earlier. Is this
> > correct? Or has ws been modified to support 4 digit years?
> >
> > thanks
> >
> > Julian Thornhill
> >
> >
> >
> > At 11:54 10/12/99 -0500, you wrote:
> > >The ws in versions prior to 4.20 links in the known bad
> > >Watcom lib routines, as documented on our y2k web page.
> > >I didn't know about a non-compliance in later ws utilities
> > >before it had been dropped from the product.
> > >
> > >Can you give me more details?
> > >
> > >Thanks,
> > >
> > >Eric
> > >
> > >Julian Thornhill wrote:
> > > >
> > > > A colleague in Japan has informed me that ws (as supplied QNX 4.22 and
> > > > below) is not y2k compliant. Is this correct/ I see no mention of it on
> > > > your web site. If it is not compliant is there a fix?
> > > >
> > > > thanks
> > > >
> > > >
> > > > Julian Thornhill
> > >
> > >--
> > >Eric Johnson (eric@qnx.com; also eajohnson@acm.org)
> >
> > Julian Thornhill
>
>--
>Eric Johnson (eric@qnx.com; also eajohnson@acm.org)
>Quality Assurance Manager, QNX Software Systems Ltd.
>Ottawa, Ontario, Canada    http://www.qnx.com
>QNX Year 2000 Information: http://www.qnx.com/support/y2k

Julian Thornhill


-------------------------------------------------------------------------------
From darn-qnx Tue Dec 14 02:12:22 1999
Date: Mon, 13 Dec 1999 17:12:17 GMT
From: Julian Thornhill
To: Sessai
Subject: ws and y2k

This is what QNX have to say about ws for anyone (like me) who are still 
using it:

I've tested it briefly and haven't been able to make it
fail with the Oct 28 1992 version available for free on QUICS.
It doesn't support 2-digit years past 1999, but 4 digit years
function correctly. I wasn't able to duplicate the 2010 failure -
even using the undocumented '1xx' year format e.g.
ws -a 'UTC 01/01/120' 'echo @' will show my Jan 2030 test file.
If you could provide more detail I will be happy to investigate
until I have an explanation for that.
I have relinked a new 16-bit ws so that it will support 2-digit
year windowing, and have posted that under /usr/free on QUICS
(/usr/free/qnx4/os/utils/misc/ws). You will have to add back
execute permission after downloading it.
I would recommend that you change your scripts to use 4-digit
years anyway - it is better practice.
- Eric

Julian Thornhill

Ionospheric Physics Group
Leicester University

-------------------------------------------------------------------------------
From Sessai Tue Dec 14 15:34:46 1999
Date: Tue, 14 Dec 99 15:34:35 JST
To: darn-qnx
Subject: Re:  ws and y2k
Cc: JTH Kikuchi Sessai

Hi, Julian and all,

OK, I understand what you meant.
It seemes I confused a bit.
This looks not a Y2K problem,
but some bugs in ws command itself.
Yes, I should say that
	there DOES(DID) exist some bug in the old ws.

The old ws command on QNX4.22A has some bug.
Year 2010 looks OK now, so maybe my mistake.
But the ws command cannot handle time
	after 06:28:16 Feb 7. 2036	(very strange timimg! What's it?)
which is before 32bits Unix time upper limit(03:14:07 Jan 19.2038).
e.g.
	ws -a "07/02/2036 06:28:15" "echo @"	works
	ws -b "07/02/2036 06:28:15" "echo @"	works
	ws -a "07/02/2036 06:28:16" "echo @"	NOT work!!
	ws -b "07/02/2036 06:28:16" "echo @"	NOT work!!
	ws -b "07/02/136 06:28:16" "echo @"	NOT work!!
	ws -b "19/01/2038 03:14:07" "echo @"	NOT work!!

I've just downloaded the new 'ws' from QUICS.
Oh, the file time stamp is Yesterday!
They've just fixed it?!?!?!

Now the new free ws command works OK.
They must have fixed the problem (just recently for us!?)

It seems taht they have added some more useful fuetures...
	OLD ws -a "01/01/00 00:00:00" "echo @"	NOT work ("Invalid year")
	OLD ws -a "19/01/38 03:14:07" "echo @"	NOT work ("Invalid year")
but now the
	New ws -a "01/01/00 00:00:00" "echo @"	works!
	New ws -a "19/01/38 03:14:07" "echo @"	works!
Now
	for 2-digit year
		00-38		+2000	(Not allowed by old ws)
		70-99		+1900
	for 3-digit year
		100-138		+1900	(bug existed for 136-138 in old ws)
	for 4-digit year
		1970-2038	valid	(bug existed for 2036-2038 in old ws)

Now everything looks OK. I'm very happy.
Please pass my regards to Eric@QNX.

So everyone can now safely move from old buggy ws to new ws command on quics.

My version 'wss' can work even after unix time limitation (up to year 2100)!!
	wss -b 2038 1 19 03 14 07 . "echo @"	works! of course.
	wss -b 2038 1 19 03 14 08 . "echo @"	also works!!
	wss -b 2100 12 31 23 59 59 . "echo @"	also works!!
And many other time-famliy commands are included which may still interests you.
	ftime		- show all 4 kinds of file time stamp in unix time
	ut2ymdhms	- convert from unix time to YYYY/MM/DD hh:mm:ss
	ut2yys		- convert from unix time to year and year_sec
	ymd2wd		- convert from YYYY/MM/DD to day of week
	ymd2yd		- convert from YYYY/MM/DD to day of year
	ymdhms2ut	- convert from YYYY/MM/DD hh:mm:ss to unix time
	ymdhms2ys	- convert from YYYY/MM/DD hh:mm:ss to year_sec
	yyd2ymd		- convert from year and year_sec to YYYY/MM/DD
	yys2ut		- convert from year and year_sec to unix time
	yys2ymdhms	- convert from year and year_sec to YYYY/MM/DD hh:mm:ss
	yesterday	- show tomorrow's date
	tomorrow	- show yesterday's date
		etc...

Best regards,
Sessai
------------------------------------------------------------------------------
> This is what QNX have to say about ws for anyone (like me) who are still 
> using it:
> 
> I've tested it briefly and haven't been able to make it
> fail with the Oct 28 1992 version available for free on QUICS.
> It doesn't support 2-digit years past 1999, but 4 digit years
> function correctly. I wasn't able to duplicate the 2010 failure -
> even using the undocumented '1xx' year format e.g.
> ws -a 'UTC 01/01/120' 'echo @' will show my Jan 2030 test file.
> If you could provide more detail I will be happy to investigate
> until I have an explanation for that.
> I have relinked a new 16-bit ws so that it will support 2-digit
> year windowing, and have posted that under /usr/free on QUICS
> (/usr/free/qnx4/os/utils/misc/ws). You will have to add back
> execute permission after downloading it.
> I would recommend that you change your scripts to use 4-digit
> years anyway - it is better practice.
> - Eric
> 
> Julian Thornhill
-------------------------------------------------------------------------------