Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automating sudo

Status
Not open for further replies.

EchoCola

Programmer
Apr 13, 2004
48
US
I'm trying to create a here document to automate the sudo command. Anyone have any experience with this? This is what I have but it's not working, it still prompts for password:

Code:
!/usr/bin/ksh

sudo - root pkgadd <<HereDoc
password
HereDoc

I found this:


..but I would rather stay away from external tools.

Thanks for your help!
 
Why not use the NOPASSWD: option in /etc/sudoers to avoid the password prompt? I'm pretty sure it won't read the password from stdin.

Also there's no need for "- root", just sudo pkgadd should suffice.

Incidentally, you don't need to use a here document to answer the pkgadd prompts, you can use an admin file instead to supply your answers in advance. See man -s4 admin and man pkgadd for details.

Annihilannic.
 
Annihilannic,

Thanks for your response. I will look into that option. Unfortunately we are using a custom written version the sudo command. Why? I don't know. I have to use the " - root" because for this command, I need to specify the user. I will look into that man file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top