1833681 Members
4578 Online
110062 Solutions
New Discussion

password in shell file

 
Donald Thaler
Super Advisor

password in shell file

when we run a script out of cron no password is required. when we try to run the script from the command line, it asks us for a password. how can i run this shell script and either pass it a password or like cron not ask for the password?
9 REPLIES 9
Sridhar Bhaskarla
Honored Contributor

Re: password in shell file

Hi,

Is that cronjob running as root where it does "su - user -c " ?. For root, it won't prompt for the password. For any user other than 'user', it will.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Olivier Decorse
Respected Contributor

Re: password in shell file

I suppose that you talk about root cron, and that your script contains something like :
su user -c "unix_script arguments"

From root account, no passwd is requied for this command.
But from an other user, from shell, you have to give a passwd.

Can you confirm and/or give an extract from your script shell ?

Olivier.
They say "install windows 2k, xp or better", so i install unix !
Geoff Wild
Honored Contributor

Re: password in shell file

Can you post script?

Who is running script?

From command line and from cron?

If root - and it's a su to some user - then no password required....

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Muthukumar_5
Honored Contributor

Re: password in shell file

cron execution is based on root user. When you try that script on user then it will be as user one.

You can use r* commands on this.

make .rhosts on user's home directory and allow between the user's to not ask passwd

Example:

between root and test user then,

.rhosts on root user home dir
localhost test

.rhosts on test user home dir
locahost root

It will not ask passwd.

Easy to suggest when don't know about the problem!
Donald Thaler
Super Advisor

Re: password in shell file

Thanks all. I was logged on as 'oracle' and running a script that had the following entry
'su - oracle -c "u01/scripts/courseTitleCursor.shl" and it would prompt me for a password. if i just run the script "courseTitleCursor.shl" everything seems to be ok.

Thanks again
Sridhar Bhaskarla
Honored Contributor

Re: password in shell file

Hi,

Yep. Even to su to the same login, it will prompt for a password. If you run it as root, it won't.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Sundar_7
Honored Contributor

Re: password in shell file

When u are logged in as oracle, why to again su - oracle ? you can directly execute the script.

if you have cron jobs scheduled for oracle and if you would like oracle's .profile to be sourced before executing the script in cron, then edit the script that is executed by cron and add

. ~oracle/.profile
<script>

This will ensure oracle's .profile is sourced before executing the script.

-- Sundar
Learn What to do ,How to do and more importantly When to do ?
Olivier Decorse
Respected Contributor

Re: password in shell file

Don't forget to assign points, if any response help you.

Olivier.
They say "install windows 2k, xp or better", so i install unix !
Muthukumar_5
Honored Contributor

Re: password in shell file

By default,

IF you try to use su from users other than root it will prompt eventhough it is same user.

And try to use the absolute path on the execution on shell script with su. So the problem of passwd promption is on using su for the same user.


Easy to suggest when don't know about the problem!