- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need to learn how to pass user/pass as arguments.
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 09:36 AM
тАО10-06-2009 09:36 AM
Thanks
# It sets up the environment variables needed by the other programs. You must pass in the Oracle User ID and Password as arguments
# ARGUMENTS: 1 - Oracle User Id
# 2 - Oracle Password
export ORACLE_USER_ID=doctor
export ORACLE_PASSWORD=4j88dk8
if [ $# -ne 2 ]
then
echo
echo "Must supply the following arguments in this order: "
echo
echo "User ID"
echo "Oracle Password"
echo
exit
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 09:42 AM
тАО10-06-2009 09:42 AM
Solution"Passing arguments" infers declaring them on the command line. For example:
# cat ./showme
#!/usr/bin/sh
[ $# != 2 ] && { print -u2 "Two arguments expected!"; exit 1; }
typeset ID=$1
typeset PASS=$2
echo "ID=${ID} password=${PASS}"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 10:11 AM
тАО10-06-2009 10:11 AM
Re: Need to learn how to pass user/pass as arguments.
typeset ORACLE_USER_ID=$1
typeset ORACLE_PASSWORD=$2
echo "ORACLE_USER_ID=${doctor} ORACLE_PASSWORD=${4j88dk8}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 10:19 AM
тАО10-06-2009 10:19 AM
Re: Need to learn how to pass user/pass as arguments.
> So to insert into my script I would use this format to pass the arguments?
The script snippet I showed demonstrates just one way to test for two-arguments (seen by the shell as $1 and $2 when passed in on the command line); give them meaningful names (with or without 'typeset') and echo what was received.
You would run the script like:
# ./showme myid mypass
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 11:17 AM
тАО10-06-2009 11:17 AM
Re: Need to learn how to pass user/pass as arguments.
scriptname doctor 4j88dk8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 11:27 AM
тАО10-06-2009 11:27 AM
Re: Need to learn how to pass user/pass as arguments.
Below is the text from the script based on what you are saying I would have to pass the arguments in this script then run the script like ./oraclescript.sh myid mypass?:
# This shell should be customized by each state.
# It sets up the environment variables needed by the
# other programs.
# You must pass in the Oracle User ID and Password as arguments
# ARGUMENTS: 1 - Oracle User ID
# 2 - Oracle Password
#if [ $# -ne 2 ]
#then
# echo
# echo "Must supply the following arguments in this order: "
# echo
# echo "User ID"
# echo "Oracle Password"
# echo
# exit
#fi
# ENVIRONMENT VARIABLES
# ORACLE_USER_ID - user id to log in to Oracle
# ORACLE_PASSWORD - password to log in to Oracle
# Ups_Home - path to head directory of UPS
# Ups_In - path to the Transaction update files that
#get uploaded from the units
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 11:59 AM
тАО10-06-2009 11:59 AM
Re: Need to learn how to pass user/pass as arguments.
I don't understand what you mean by this.
>>then run the script like ./oraclescript.sh myid mypass?:
Yes. Just run the script like that. Nothing else should be required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-06-2009 12:59 PM
тАО10-06-2009 12:59 PM
Re: Need to learn how to pass user/pass as arguments.
> I would have to pass the arguments in this script then run the script like ./oraclescript.sh myid mypass?:
I suppose you want something like:
#!/usr/bin/sh
[ $# != 2 ] && { print -u2 "Two arguments expected!"; exit 1; }
typeset ORACLE_USER_ID=$1
typeset ORACLE_PASSWORD=$2
export ORACLE_USER
export ORACLE_PASSWORD
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 01:55 AM
тАО10-07-2009 01:55 AM
Re: Need to learn how to pass user/pass as arguments.
>typeset ORACLE_PASSWORD=$2
>echo "ORACLE_USER_ID=${doctor}
ORACLE_PASSWORD=${4j88dk8}"
the last line is wrong. correction:
echo "ORACLE_USER_ID=${ORACLE_USER_ID}
ORACLE_PASSWORD=${ORACLE_PASSWORD}"
you should run your script this way:
# ./showme myid mypass
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 01:57 AM
тАО10-07-2009 01:57 AM
Re: Need to learn how to pass user/pass as arguments.
>echo "ORACLE_USER_ID=${doctor} \
ORACLE_PASSWORD=${4j88dk8}"
the last line is wrong. correction:
echo "ORACLE_USER_ID=${ORACLE_USER_ID} \
ORACLE_PASSWORD=${ORACLE_PASSWORD}"
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 05:26 AM
тАО10-07-2009 05:26 AM
Re: Need to learn how to pass user/pass as arguments.
#scripttorun.sh doctor 4j88dk8
doctor being the username
4j88dk8 being the password
That should work without need to modify the script. Can someone confirm else I will try it tonight and update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 05:31 AM
тАО10-07-2009 05:31 AM
Re: Need to learn how to pass user/pass as arguments.
> I was reading through the arguments section of the manual last night and it appears I will be able to supply the arguments...[this] should work without need to modify the script. Can someone confirm else I will try it tonight and update.
Write a test script if you are in doubt, or comment-out the pieces that would cause "real work" to be done that you might not want done in a test scenario.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 06:07 AM
тАО10-07-2009 06:07 AM
Re: Need to learn how to pass user/pass as arguments.
> #scripttorun.sh doctor 4j88dk8
When you get this to work, and you start
using it, will any user on the system be able
to use the "ps" command to see this password?
If so, why have a password?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 06:25 AM
тАО10-07-2009 06:25 AM
Re: Need to learn how to pass user/pass as arguments.
I am new to scripting so figuring out how to "pass the username and password" as arguments was really the main issue. I should be able to get it going thanks to this thread.
Steven,
As far as I can tell on my system it cannot be seen with ps. I thought ps would just show running processes not sure how it would pull the username and password or if it is even possible to see with ps. Someone more experienced would be able to answer better. As far as why, to your question, because that is how I was instructed to do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 07:15 AM
тАО10-07-2009 07:15 AM
Re: Need to learn how to pass user/pass as arguments.
> be seen with ps. [...]
On _my_ system:
dy $ uname -a
HP-UX dy B.11.11 U 9000/785 2012616114 unlimited-user license
dy # cat slow.sh
#!/bin/sh
echo "args: $@"
sleep 300
dy # ./slow.sh abc def ghi
args: abc def ghi
Meanwhile, as a normal user:
dy $ ps -ef | grep [s]low
root 3423 1688 0 10:09:20 pts/0 0:00 /bin/sh ./slow.sh abc def ghi
Can you see the arguments? I can.
> I thought ps would just show running
> processes [...]
And your script won't be a running process?
One of us seems to be missing something.
> [...] because that is how I was instructed
> to do it.
And if someone told you to jump off a cliff,
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 07:16 AM
тАО10-07-2009 07:16 AM
Re: Need to learn how to pass user/pass as arguments.
Instead of this, you should prompt for the password in interactive mode, and set the echo off - this way the password won't be visible to the terminal. Here is a hint how to prompt for the password in interactive mode:
#######################################
#!/usr/bin/ksh
echo -n "Please type in your password: "
stty -echo
read PASS
stty echo
echo "\nYour pass is:\t$PASS"
#######################################
This is how it works: (it prints the password at the end)
$ ./get_pass.sh
Please type in your password:
your pass is: test
$
You could write a script that gets the username as the first parameter, and prompts for the pass at runtime...
$ ./myscript.sh username
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 07:25 AM
тАО10-07-2009 07:25 AM
Re: Need to learn how to pass user/pass as arguments.
#######################################
#!/usr/bin/ksh
# getpass.sh HP-UX version
echo "Please type in your password: \c"
stty -echo
read PASS
stty echo
echo "\nYour pass is:\t$PASS"
#######################################
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 08:20 AM
тАО10-07-2009 08:20 AM
Re: Need to learn how to pass user/pass as arguments.
While I don't appreciate your tone I do appreciate the content of what you posted. I don't have time to open the admin manual right now so my question is after the process finishes running it is removed from ps, correct?
Viktor,
Thanks for that. Originally that is how the code prompted for a username and password. The reason for the potential switch is that I am trying to find a possible way to cron this process nightly. What I was thinking was:
05 07 * * * /var/scripts/scrun.sh user pass
I have not researched yet if I could set up a cron like that so I may just be spinning my wheels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 10:23 AM
тАО10-07-2009 10:23 AM
Re: Need to learn how to pass user/pass as arguments.
Yes you can set up a cron job like that. No problems there.
>>...so my question is after the process finishes running it is removed from ps, correct?
Yes, when a process finishes running it is removed from the process table, which is what ps queries.
The risk is that while the script is running, the user name and password WILL be visible in the ps output.
This is a big no no in some auditors eyes. If you are subject audits for SOX, HIPAA, or some of the other myriad legislation, you may get dinged for this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 11:25 AM
тАО10-07-2009 11:25 AM
Re: Need to learn how to pass user/pass as arguments.
Thanks for the information. Our processes are very quick, max 30 seconds. Ultimately is seems you wouldnt want to pass the username and password in that manner if avoidable.
Thanks everyone for you help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 11:26 AM
тАО10-07-2009 11:26 AM
Re: Need to learn how to pass user/pass as arguments.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-07-2009 02:51 PM
тАО10-07-2009 02:51 PM
Re: Need to learn how to pass user/pass as arguments.
> 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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2009 12:52 AM
тАО10-08-2009 12:52 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2009 04:42 AM
тАО10-08-2009 04:42 AM
Re: Need to learn how to pass user/pass as arguments.
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2009 05:07 AM
тАО10-08-2009 05:07 AM
Re: Need to learn how to pass user/pass as arguments.
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.