Login issue within a shell script

adamk84

New Member
Hi,
I was looking to have some ideas on how I can get this connection working: I have a Unix shell script that runs a .pf file, but I was looking to have the username from the unix system assigned to the -U parameter within the pf file.

Sample of my unix script (Excerpt):

DBS=/dba/db
SRC=/dba/src
USR=$HOME/dev/dba
PROPATH=".,/dba/rt,/dba/prolibs/system.pl,"
PATH=.:/usr/bin:$DLC/bin
startpgm='-pf /export/home/adamk/bin/dba.pf -p systart.p'
tempdir='-T /var/tmp/protmp'

Sample of the pf file:
-db /dba/db/system -U

I have tried using the following for where the '-U' is... os-getenv("USER"), $USER

With no luck thus far, anyone have any suggestions on how to get this connection working? I know that if I set the -U parameter explicitly to the actual username like -db /dba/db/system -U "adamk" works, but I am needing the username to be set by the OS and not by manually entering it.

Thanks,
Adam

Openedge 10.2a
 
Hi Adam ,

Can you try replacing the "adamk" with `whoami` in the pf file .. so the pf file content would be something like -

-db /dba/db/system -U `whoami`

Thanks,
Rudra
 

RealHeavyDude

Well-Known Member
In order to achieve this you need to supply the -U parameter in the shell script and not in the parameter file. AFAIK there is no logic in place that would replace parameters with placeholders when Progress parses a parameter file. Plus, you can't run a parameter file - instead you can use a parameter file for example when you start a Progress session or database to specify session or database broker settings.

The OS-GETENV function is a 4GL function that you can only use when a 4GL session is already established - but not on the command line or in a parameter file.

BTW, you can specify parameters either on the command line or in a parameter file - the last occurrence will win.


HTH, RealHeavyDude.
 

adamk84

New Member
Hi Adam ,

Can you try replacing the "adamk" with `whoami` in the pf file .. so the pf file content would be something like -

-db /dba/db/system -U `whoami`

Thanks,
Rudra

This does not work as it will fail on the 'whoami' section " ** Your Password and Userid whoami do not match. (710)".
However I did find a work around as I will just remove what was in the .pf file and code it into the startup program so that it runs similar connections.
Within the .p program I just ran a CONNECT /dba/db/system -ld system -U VALUE(OS-GETENV("USER")) which gets me around the issue of having to pass any parameters to the .pf file.

Thanks for both of your responses.
 

RealHeavyDude

Well-Known Member
You ended up with what I usually recommend. Establish the Progress session and then connect to the necessary databases using the CONNECT statement. Doing this enables you to do many things, but most of all, you are able to handle failed database connects in your code preventing the session to crash with no meaningful error message for the user in the first place.

Regards, RealHeavyDude.
 
Top