passing password in a script when become anot

July 10, 2011 at 22:29:03
Specs: Solaris 10
Hi guys,

I am using Solaris 10 and after login, I need to become another account to stop and start some services. it will be like:

bash-3.00$ become archival
Password:
bash-3.00$ stopOD.ksh
bash-3.00$ startOD.ksh
bash-3.00$ exit
bash-3.00$ become hkarchival
Password:
bash-3.00$ stopOD.ksh
bash-3.00$ startOD.ksh
bash-3.00$ exit
..........
..........
..........

I need to do this for 10 times everyday. Can someone please guide me how to write a shell script where I just run the script then it can pass in the password and executing services.

Thanks & regards,
Mark


See More: passing password in a script when become anot

Report •

#1
July 11, 2011 at 01:36:13
You might want to look at using expect.

Report •

#2
July 11, 2011 at 02:21:09
bash-3.00$ man expect
No manual entry for expect.

Report •

#3
July 11, 2011 at 09:32:07
It's possible that expect is not initially bundled with Solaris 10. Check out this link:

http://www.computing.net/answers/un...

It shows an example of using expect and the expect home page where you might be able to download it.

In your example, you are using executing something called "become" What is that? It looks like an alias for something else - sudo perhaps?

Anyway, it you do come with a script that passes the password correctly, you will probably have to source it to update your parent shell:

# that's a period in front
. <my_script>


Report •

Related Solutions

#4
August 31, 2011 at 16:55:18
If you didnt figure out this issue. try the sh -c command you can specify a user to execute a command as.

Report •

Ask Question