Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.05; 'needed,': 0.07; 'assuming': 0.09; 'read-only': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:/ 10': 0.09; 'subject:script': 0.09; 'wrote': 0.14; 'file;': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'recognizing': 0.16; 'sortable': 0.16; 'sparks': 0.16; 'storing': 0.16; 'sudo': 0.16; 'wrote:': 0.18; 'user.': 0.19; 'machine': 0.22; 'preferred': 0.22; 'print': 0.22; 'creating': 0.23; 'script.': 0.24; 'simpler': 0.24; 'versions': 0.24; 'sort': 0.25; 'extension': 0.26; 'header:X -Complaints-To:1': 0.27; 'wondering': 0.29; 'chris': 0.29; 'usually': 0.31; 'directory,': 0.31; 'flags': 0.31; "user's": 0.31; 'file': 0.32; 'there.': 0.32; 'there,': 0.34; 'subject:the': 0.34; 'problem': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'disk': 0.36; 'done': 0.36; 'subject:?': 0.36; 'so,': 0.37; 'clear': 0.37; 'skip:. 20': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'called': 0.40; "you're": 0.61; 'first': 0.61; 'information': 0.63; 'such': 0.63; 'more': 0.64; 'home': 0.69; 'user,': 0.69; 'obvious': 0.74; 'technique': 0.93; 'subject:Check': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dave Angel Subject: Re: Check to see if the script has been previously used? Date: Tue, 27 May 2014 07:05:21 -0400 (EDT) Organization: news.gmane.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: dpc6744199209.direcpc.com X-Newsreader: PiaoHong.NewsGroup.Client.VIP:1.52 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1401188699 news.xs4all.nl 2872 [2001:888:2000:d::a6]:43981 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:72108 Chris Angelico Wrote in message: > On Tue, May 27, 2014 at 5:45 PM, KC Sparks 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/ as a directory, and storing information > there. Either technique works well for recognizing a first-time user. > > ChrisA > The problem can be simpler if you're assuming a machine with only one user, or more complicated if the obvious disk location is either read-only to the user, or volatile. You also might want to clear all such flags upon an upgrade. If so, it's not just a file needed, but a sortable version string. Preferred approach is usually to respond to one of the conventional argv switches. And let the user decide. -- DaveA