Operating System - HP-UX
1756688 Members
3632 Online
108852 Solutions
New Discussion юеВ

Re: Need to learn how to pass user/pass as arguments.

 
SOLVED
Go to solution
Mrg_2
Advisor

Re: Need to learn how to pass user/pass as arguments.

Solution found in the thread, more good informatin coming. So going to reopen.
Steven Schweda
Honored Contributor

Re: Need to learn how to pass user/pass as arguments.

> Our processes are very quick, max 30
> seconds. [...]

Yeah. No one could possibly write a script
to run "ps" repeatedly, until he got the
desired result.

> Yes you can set up a cron job like that.

Storing a password in a crontab file is just
about as wise as storing it in a shell
script. Or using it on a command line.

> Oct 7, 2009 15:15:43 GMT 2 pts

But what's my opinion worth?
Viktor Balogh
Honored Contributor

Re: Need to learn how to pass user/pass as arguments.


maybe it's not too late. for what reasons do you need a password? maybe it could be solved with a simple passwordless sudo...

****
Unix operates with beer.
Mrg_2
Advisor

Re: Need to learn how to pass user/pass as arguments.

Reopened for more good information.

Viktor,

The first script calls sets the environmental variables and passes the username and password to the next script. This is all new to me so I am not even sure it "passes" it. I do know that as I recieved the first script the instructions stated "# You must pass in the Oracle User ID and Password as arguments".

Here is an snippet from the next script.

# 1. Checks environment variables
# 2. Checks for existence of files to be processed in the /home directory
# 3. Checks then for each individual Mnemomic file. If found, the file is processed by calling a stored pl/sql procedure from the database

# Make sure environment variables are set up properly

EnvironmentOk="Y"

if [ -z ${ORACLE_HOME:-""} ]
then
EnvironmentOk="N"
fi

if [ -z ${ORACLE_USER_ID:-""} ]
then
EnvironmentOk="N"
fi

if [ -z ${ORACLE_PASSWORD:-""} ]
then
EnvironmentOk="N"
fi


Viktor Balogh
Honored Contributor

Re: Need to learn how to pass user/pass as arguments.

Ok, this case step #3 of the second script should be re-written that it runs the pl/sql procedures in the name of the oracle user.
I think it would be the best to make a backup of the second script like this:

cp second.sh second_root.sh

and rewrite this second_root.sh - technically you should insert some sudo in front of the commands. And after that be sure to modify /etc/sudoers with visudo to have the passwordless sudo working!


****
Unix operates with beer.
Mrg_2
Advisor

Re: Need to learn how to pass user/pass as arguments.

Snippet from part 3:

echo "Loading..... " $file
sqlplus -s $ORACLE_USER_ID/$ORACLE_PASSWORD < execute loadnpsg('$file');

So you are saying I should add the Oracle user id and oracle password in this section instead of it looking for them? So it would look like this:

echo "Loading..... " $file
sqlplus -s username/password < execute loadnpsg('$file');

Also for the sudo part you are saying to use #sudo programtoexecute.sh ??

Thanks
Viktor Balogh
Honored Contributor

Re: Need to learn how to pass user/pass as arguments.

sorry for the late answer, the notification didn't work for some reason.

>"Snippet from part 3:

echo "Loading..... " $file
sqlplus -s $ORACLE_USER_ID/$ORACLE_PASSWORD <execute loadnpsg('$file');"

ok, this an interactive script.

>" The reason for the potential switch is >that I am trying to find a possible way to >cron this process nightly."

If you want to have run it from cron you should burn in the username/password and leave interactivity.

"echo "Loading..... " $file
sqlplus -s username/password <execute loadnpsg('$file');"

It is right. Not the sudo way, but you should skip interactivity. In our environment sqlplus don't prompt for the password, but I don't really know it how it was done.
****
Unix operates with beer.
Mrg_2
Advisor

Re: Need to learn how to pass user/pass as arguments.

Got it!

Thanks for all the help.