on 04-20-2011 6:24 AM
Hello,
Can you tell me the command to input username and password to login from shell script?
I just know this -
su - sidadm -c "stopsap"
But this just logs in using Username - sidadm.
how do modify this to add password also in command line?
Thanks everyone.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> But this just logs in using Username - sidadm.
> how do modify this to add password also in command line?
You don't wanna do that; everyone who can read that script will know the password.
What do you want to accomplish and what is your operating system?
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its a simple stopsap script.
When I test the script as
su - sidadm -c "stopsap"
It stops and asks for password. I do not have root access, so this script is in crontab of sidadm.
Secondly, to protect the password, I would grant only rwx access to the user sidadm and no access to group and others.
So I would be grateful, if you could tell me the syntax of using password in script.
Thanks.
> When I test the script as
> su - sidadm -c "stopsap"
> It stops and asks for password. I do not have root access, so this script is in crontab of sidadm.
There are tools to do exactly that without a password - it's called "sudo".
man sudo
> Secondly, to protect the password, I would grant only rwx access to the user sidadm and no access to group and others.
The "other user" must have execute right too.
Markus
There are tools to do exactly that without a password - it's called "sudo".
sudo is disabled by AIX team
The "other user" must have execute right too.
Since its just stopsap and startsap, they would be owned by sidadm only and executed by sidadm only through crontab
I am guessing you do not know the syntax to use password in comman line on shell script
but in Crontab it doesn't run.
That's a common problem that confuses newbies again and again.
When you start a script interactively, it will get all the environment variables (like $PATH and so on) from your login. But for crontab, you have to take care for the environment variables yourself.
This has been explained again and again, in Unix forums and elsewhere.
Google is your friend.
> sudo is disabled by AIX team
So they abandon a fine granular security option with password in shell scripts I wonder what an auditor will say to that!
> I am guessing you do not know the syntax to use password in comman line on shell script
I know how it can work - using expect:
http://en.wikipedia.org/wiki/Expect
but I'm even more looking forward for the guy auditing your IT
Markus
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.