Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to read date and time

How to read date and time

How to read date and time

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

RE: How to read date and time

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

RE: How to read date and time

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

RE: How to read date and time

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

Your PostScript expert is just a click away.

RE: How to read date and time

Thanks alexcher, can you lead me into the PS commands to achieve it?

Regards, dba2

RE: How to read date and time

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.
  /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.

RE: How to read date and time

Many thanks alexcher, just what I needed!

Regards, dba2

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close