Mail Archives: cygwin/2004/08/28/11:41:29
On Sat, 28 Aug 2004, Hannu E K Nevalainen wrote:
> Igor wrote:
> > On Fri, 27 Aug 2004, Igor Pechtchanski wrote:
> >
> >> [snip]
> >> Or you could try to get a SYSTEM-owned shell, and remove it from
> >> there. FWIW, I have a handy shortcut for that (see below).
> >
> > Sorry, I forgot to include the promised shortcut. Here it is:
> >
> > C:\cygwin\bin\bash.exe -c "at $(date +%H):$(($(date +%M) + 1)) /interactive 'c:\cygwin\bin\bash.exe' --login -i; secs=$((60 - $(date +%S))); while [ $secs -ne 0 ]; do echo -ne 'Please wait '$secs' seconds for the shell \r'; sleep 1; secs=$(($secs - 1)); done"
> >
> > Just paste the above line in the "Target:" field of the shortcut.
> > What this will do is show a window with the countdown until the
> > system-owned login shell pops up. If you want to make it really
> > nice, set the width of the shortcut screen buffer (in the Layout tab)
> > to 38 and the height to 1.
> >
> > The above assumes you installed Cygwin in c:/cygwin. If you
> > installed it somewhere else, the shortcut needs to be modified
> > accordingly.
> > HTH,
> > Igor
>
> Hmm... I wasn't able to get your shortcut working. First it didn't fit in
> the shortcut wizards textbox.
Yeah, it does push the command length limits, doesn't it? ;-)
> Then after having put it in "isysbash.bat" it failed with
>
> $ isysbash.bat
> bash: -c: line 1: unexpected EOF while looking for matching `)'
> bash: -c: line 2: syntax error: unexpected end of file
> $ cat isysbash.bat
> @echo off
> C:
> cd \Program\Cygwin\bin\
> bash.exe -x -c "at $(date +%H):$(( $(date +%M) + 1 )) /interactive 'bash.exe' --login -i; secs=$(( 60 - $(date +%S) )); while [ $secs -ne 0 ]; do echo -ne 'Please wait' $secs 'seconds for the shell \r'; sleep 1; secs=$(( $secs - 1 )); done"
>
> Counting the parentheses; They match! Heh? What is the problem?
This is the standard batch file % problem -- it interprets all %* as
variables (and the ":" as a modifier). You need to quote each %, i.e. use
bash.exe -x -c "at $(date +%%H):$(( $(date +%%M) + 1 )) /interactive 'bash.exe' --login -i; secs=$(( 60 - $(date +%%S) )); while [ $secs -ne 0 ]; do echo -ne 'Please wait' $secs 'seconds for the shell \r'; sleep 1; secs=$(( $secs - 1 )); done"
BTW, the spaces after "$((" and before "))" are redundant.
> Your scripting also have a problem at hour boundaries. (Launch it
> "imaginary" at 11:59 or 23:59).
Yes, true. I've looked long and in vain for a way of converting the date
from pure second counts (you can convert *to* the second count using the
"%s" GNU extension). If anyone finds such a way, please let me know. Of
course, one can always use perl, but that seems a bit heavyweight for such
a purpose.
> There might also be a problem with "at" not accepting single digit
> hours, I'm not as sure about that though.
Nope, the "%H" format always outputs the hours as double digits in 24-hour
format.
> I've attached my "sysbash", which WFM.
> Who knows there might be problems with it too ;-P
Well, not so much as a problem, just seems too complex. Why call *bash*
through *cmd /c*??? Why bother with control codes? Wouldn't something
like the below script be much simpler?
--------------------- BEGIN script ---------------------
#!/bin/bash
export CYGWIN="$CYGWIN check_case:adjust"
AT="`which at 2>/dev/null`"
[ -z "$AT" ] && echo "\"at.exe\" not found" >&2 && exit 1
CMD="$(cygpath -aw /bin/bash.exe) --login -i"
HHMM="$(echo "$(date "+%H +%M")" | awk '{printf("%02d:%02d",($2>58)?($1+1)%24:$1,($2>58)?0:($2+1))}')"
"$AT" "$HHMM" /interactive $CMD
# Countdown
secs=$((60 - $(date +%S))); while [ $secs -ne 0 ]; do echo -ne 'Please wait' $secs 'seconds for the shell \r'; sleep 1; secs=$(( $secs - 1 )); done
---------------------- END script ----------------------
Oh, and at.exe doesn't exist under Win9x normally, but there's a MSDN
sample that can be compiled and should work on Win9x:
<http://msdn.microsoft.com/library/en-us/vcsample98/html/vcsmptasksched.asp>.
HTH,
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D.
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing." -- Dr. Jubal Harshaw
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -