PxPlus User Forum

Twitter Twitter Twitter

Author Topic: password protected data files  (Read 984 times)

PMM_CAI

  • Silver Member
  • ***
  • Posts: 27
    • View Profile
password protected data files
« on: October 12, 2020, 11:32:09 AM »
Greetings all; hope this finds everyone well during this time.

A question re: password-protected (PP) data files. We have a utility that runs through our data files, and it's supposed to run unattended, no interaction until it completes. As it loops through the files, the code attempts an open input on each (primarily to determine if it exists). With the pwd protection on a file(s), it now pops the prompt for the pwd if the file in question is PP. See attached.

So the question is: can we somehow predetermine that it is PP without the user interaction. The PxPlus panel in question, in the pgm _ext\system\get_pswd, launches automatically. I couldn't see a way to trap it before the panel displays. If a file is PP, we'll skip it.

TIA!

Paula McKeever
CAI Software LLC

jasonc

  • Silver Member
  • ***
  • Posts: 22
    • View Profile
Re: password protected data files
« Reply #1 on: October 12, 2020, 03:20:00 PM »
Paula,
Looking at _ext\system\get_pswd, it appears that you can set %z_password prior to opening the file and you won't be asked for the password.  Assuming these files have the same password, you could have your utility program set that variable prior to checking files.

Alternatively, if you are only looking to see if the file exists, you could do this:
open(hfn,ISZ=-1) "filename"

RobL

  • Silver Member
  • ***
  • Posts: 21
    • View Profile
Re: password protected data files
« Reply #2 on: October 12, 2020, 04:26:16 PM »
Hi Paula,

You could try opening the files with a dummy (or null) password and then process the returned error code. Here's an example;

begin
!
! create a file with no password
erase "FileNoPass",err=*next
keyed "FileNoPass",[1:1:10],0,0
!
open (1)"FileNoPass"
write (1)"test","some data"
close (1)
!
! create a file with a password
erase "FileWithPass",err=*next
keyed "FileWithPass",[1:1:10],0,0
!
open lock (1)"FileWithPass"
password (1)"secret" required for open and on data
write (1)"test","some data"
close (1)
!
! process list of files
for filename$ from "FileNoPass,FileWithPass,MissingFile,"
!
print "processing filename: ",filename$
!
filechan=unt; open input (filechan,key="",err=*next)filename$
if tcb(2) then if err=12 then print "   *** file ",filename$," is missing."
!
close (filechan)
!
next

Regards,

Rob Leighton