This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: SYSTEM-owned shell shortcut


Igor wrote:
> On Sat, 28 Aug 2004, Hannu E K Nevalainen wrote:
>> Igor wrote:
>>> On Fri, 27 Aug 2004, Igor Pechtchanski wrote:
>>>
>>>> [snip]
<SNIP>
>> 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? ;-)

 =-) that is quickly done with MS-stuff IMO.


>> 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
<snip>
>> 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

Argh! I was in bash only mode.


<SNIP>
>> 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.

FYI: The DATE() and TIME() functions of any (ANSI) REXX interpreter has nice
features wrt this; e.g. "Regina" is available at sf.net
(http://regina-rexx.sourceforge.net/) and compiled OOTB in cygwin at version
3.0 (I've yet to try the more recent versions; current is 3.3, then we also
have a new gcc since then).

-- example --
#!/usr/bin/rexx

parse arg secs .

say 'Current time:' time('n')
say 'Adding' secs 'seconds:' time('n',(time('s')+secs)//(24*60*60),'s')

/* time(ouput_format,input_time,input_time_format) */
-- cut --


>  Of course, one can always use perl, but that seems a
> bit heavyweight for such a purpose.

Well, that depends on the competition... pure bash is ofcourse the least
resource hungry; then you have these at least ;-)

$ ls -l `which rexx`
-rwxr-xr-x    1 Hannu      389468 Nov  3  2002 /usr/bin/rexx*

$ ls -l `which perl`
-rwxr-xr-x    1 Hannu       11776 Aug 19 21:47 /usr/bin/perl*

$ ls -l `which awk`
lrwxrwxrwx    1 Hannu           8 Aug 13 21:55 /usr/bin/awk -> gawk.exe*

$ ls -l `which gawk`
-rwxr-xr-x    1 Hannu      278528 Aug 13 21:55 /usr/bin/gawk*

$ rexx <<EOF
> parse version text
> say text
> EOF
REXX-Regina_3.0 4.95 25 Apr 2002

>From the above it seems perl would be the quickest to load, but then; it
does a lot of things w modules and such...

<SNIP>

>> 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?

Ahh... ;-) I knew there was issues, I even found more; addition in bash
expects OCTAL numbers if there is a leading ZERO.
This script is almost a year old and I use it only occassionally. Such is
life.

>  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
> ----------------------

Looks nice, though you're "cheating" with awk ;-). It might also be that
this has the same race issue as my script has; execution under certain
conditions might be so slow that the deployment of "at" comes too late -
postponing the launch 24 hours.

> 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/vcsmptask
> sched.asp>.

Ahh... Thats good to know if you're running W98.

Well, nuff' for now - isn't it?

/Hannu E K Nevalainen, B.Sc. EE Microcomputer systems            --72-->

** mailing list preference; please keep replies on list **

-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]