delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/11/15/15:49:55

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
Message-ID: <26363163.post@talk.nabble.com>
Date: Sun, 15 Nov 2009 12:47:52 -0800 (PST)
From: aputerguy <nabble AT kosowsky DOT org>
To: cygwin AT cygwin DOT com
Subject: Re: Would it be possible/hard to write a version of 'at' that executes "right away" to get around ssh username=SYSTEM?
In-Reply-To: <26362968.post@talk.nabble.com>
MIME-Version: 1.0
References: <26362968 DOT post AT talk DOT nabble DOT com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

And in case anyone is interested, here is a bash function that launches a
command via 'at' at the next minute and returns the number of seconds until
the launch (actually if you are less than 5 seconds before the next minute,
it waits until the minute after so that at has time to setup - you could
probably use a number smaller than 5 seconds of course)

function at_launch ()
{
    local h m s wait command
	command=$@
    set -- $(date +"%H %M %S")
	h=$((10#$1))  #Note explicitly use base 10 so that 08 and 09 not
interpreted as bad octal
	m=$((10#$2 +1)) #Advance minutes by 1
	s=$((10#$3))
	wait=$((60 - $s))
    [ $s -gt 55 ] && let "m += 1" "wait += 60" # Make sure >5 seconds left
    [ $m -ge 60 ] && let "m %= 60" "h += 1" #Overflow minutes
    let "h %= 24"
	at $h:$m $(cygpath -w $(which bash.exe)) -c \"$command\" > /dev/null
	return $wait
}
-- 
View this message in context: http://old.nabble.com/Would-it-be-possible-hard-to-write-a-version-of-%27at%27-that-executes-%22right-away%22-to-get-around-ssh-username%3DSYSTEM--tp26362968p26363163.html
Sent from the Cygwin list mailing list archive at Nabble.com.


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019