Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to read date and time 1

Status
Not open for further replies.

dba2

Programmer
May 23, 2002
16
GB
Can anyone help please?
I have a PostScript Interpreter running on a Sun Unix system and when I send a PostScript document to the Interpreter I want to be able to read the time and date. I have not been able to find any reference to PostScript Time or Date commands in the 'Red Book', are there any? If not, is it possible to use a PostScript command to run the Unix date command which I know if redirected to a file I could then use the PostScript 'file' command to read it.

Thanks, dba2
 
PostScript has no such date/time functions. For file i/o, you can use the "file" operator, and whichever read method is most suitable.

Thomas D. Greer
 
Thank you for your response Thomas. In case anyone else is hunting for a similar solution, after posting this question I found a suggestion by 'Dunkie' on Google Groups that a solution could be to have a script running in the background every minute with the output directed to a file. This I've done in crontab which should provide the solution to my problem. (Many thanks Dunkie)

Regards, dba2
 
A host-based PS interpreter can access the file system including named pipes and devices. So the possibilities are
endless.

Your PostScript expert is just a click away.
 
Thanks alexcher, can you lead me into the PS commands to achieve it?

Regards, dba2
 
The following was tested on GNU+Linux. I have no idea whethe this works on the MS-DOS family of operating systems.

Type the following on one terminal:
mkfifo foo
while true; do date >foo; done

Type the following on another terminal, in the same directory.
gs -dNODISPLAY
/t { (foo)(r) file closefile (foo)(r) file dup
28 string readstring pop = closefile} def

Now, typing t at the Ghostscript prompt shows the current time.

BTW, Ghostscript is a free software can can be easily extended to get the system time directly. It is used here
just as an example of a host-based PS interpreter.


Your PostScript expert is just a click away.
 
Many thanks alexcher, just what I needed!

Regards, dba2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top