Check to see if the script has been previously used?

Chris Angelico rosuav at gmail.com
Tue May 27 04:25:19 EDT 2014


On Tue, May 27, 2014 at 5:45 PM, KC Sparks <kcrsparks at gmail.com> wrote:
> I was wondering if there was an extension or way that would allow me to
> print instructions if it is the first the the user has used the script.

The trickiest part is defining the 'user'. Generally, this sort of
thing is done by creating a file; if the file's not there, it's the
first time. Some versions of sudo will create a file called
.sudo_as_admin_successful in the user's home directory; others create
/var/lib/sudo/<username> as a directory, and storing information
there. Either technique works well for recognizing a first-time user.

ChrisA



More information about the Python-list mailing list