cancel
Showing results for 
Search instead for 
Did you mean: 

Shell script stop and start SAP

former_member759680
Contributor
0 Kudos

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?

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member759680
Contributor
0 Kudos

Thanks everyone.

markus_doehr2
Active Contributor
0 Kudos

> 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

former_member759680
Contributor
0 Kudos

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.

markus_doehr2
Active Contributor
0 Kudos

> 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

former_member759680
Contributor
0 Kudos
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

Former Member
0 Kudos

this script is in crontab of sidadm

In this case there will be no need for a su - sidadm.

Or what am I missing here ??

former_member759680
Contributor
0 Kudos

I tried with just stopsap in the script.

When I execute the script manually, it runs.

but in Crontab it doesn't run.

Former Member
0 Kudos

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.

former_member759680
Contributor
0 Kudos

OK. Good to know. Just graduated from Unix "newbie" to "amateur".

I will use that.

So, should I take it that the "gurus" don't know the exact syntax to use password in the shell script? (back to the original question of this thread)

I mean it cant be Classified Information right, its Unix!

Former Member
0 Kudos

So, should I take it that the "gurus" don't know the exact syntax to use password in the shell script?

Unix gurus have a tool for that too.

It's called expect.

Google for it!

markus_doehr2
Active Contributor
0 Kudos

> 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