Operating System - OpenVMS
1748241 Members
3931 Online
108759 Solutions
New Discussion юеВ

Re: Inputting password from command procedure

 
Mark Vitalis
Occasional Advisor

Inputting password from command procedure

Hi All,
IтАЩm a beginner to the vms operating system, and having trouble with a command procedure to run an .exe file.
The thing is whenever a program is run on the system the user is prompted to enter a username and password before the program executes.
IтАЩm having a problem inputting this data
(password) from the command procedure, is there a way for this to be done?.

And also I was wondering, is they anyway to input the username and password from the keyboard and the rest of data from the command procedure?

Sincerely,
Mark Vitalis
7 REPLIES 7
Hein van den Heuvel
Honored Contributor

Re: Inputting password from command procedure

Mark,
Welcome to the OpenVMS ITRC Forum!

For most programs you just follow the start of the program with the data such as username password. For example

$! test.com
$run test
username
password
some data
more data
$exit

Your question implies you are concerned about putting a username/passowrd in a script. Rightly so! It woudl be best/desirable to input the password from the originating terminal, and the data from the script or the terminal as appropriate.

If the program was written to accomodate that, this is easy. Specifically the program should se tow different files/streams for the two typs of input. The password should be read from the logical name SYS$COMMAND, and the data from SYS$INPUT.
Check $HELP and USER MANUAL for details on those concepts.
However, if a program just reads from SYS$INPUT (the standard for C, Fortran and so on), then you are pretty much stuck. There is no way to redirect on the fly.

Enjoy,
Hein.

Mark Vitalis
Occasional Advisor

Re: Inputting password from command procedure

Hein,

Thanks alot man, greatly appreciated.

EdgarZamora_1
Respected Contributor

Re: Inputting password from command procedure

Regarding your second question:

"And also I was wondering, is they anyway to input the username and password from the keyboard and the rest of data from the command procedure?"

You can try to put this line in your command procedure, right before you invoke the program (whose input you want to enter from the keyboard):

$ DEFINE/USER SYS$INPUT SYS$COMMAND

For example,

$ define/user sys$input sys$command
$ run myprogram !input will be from keyboard
$! program finished
$ write sys$output "Done!"
$ exit

Good luck.
Mark Vitalis
Occasional Advisor

Re: Inputting password from command procedure

Hi Edgar,
Thanks for the assistance.

Sincerely,
Mark Vitalis
Edwin Gersbach_2
Valued Contributor

Re: Inputting password from command procedure

We also use a password protected program and in some procedures it gets used multiple times. In order to avoid to have to input the password for each invocation I use the following:

$! -----------------------------------------
$! Get the password once
$! -----------------------------------------
$!
$ SET TERM/NOECHO
$ INQUIRE PWD "Util password"
$ SET TERM/ECHO
$!
$ PIPE WRITE SYS$OUTPUT PWD | -
UTIL Param1 Param2 ...

This can be extended for multiple input lines:

$ PIPE (WRITE SYS$OUTPUT USERNAM ; -
WRITE SYS$OUTPUT PWD ; -
WRITE SYS$OUTPUT "Command" ; -
WRITE SYS$OUTPUT "EXIT") | RUN UTIL

Edwin
Wim Van den Wyngaert
Honored Contributor

Re: Inputting password from command procedure

Or simply put the username + pwd in a file and read that instead.
And you can install the image with privs so that the user itself can not read the file (w:,s:rwed) but only an installed exe (all with privs).

Wim
Wim
Mark Vitalis
Occasional Advisor

Re: Inputting password from command procedure

Thank guys,
you all were very helpful, really appreciate it.

Thanks