delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2015/06/25/21:00:05

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; q=dns; s=default; b=gy+
6A3aSRj7lI53p0gv7EtXFlvcAvI8S/LOmTDzZq3DO5KkT0+JKHBaReHEHqNC/BAK
uNd2TnP3/UxYHEitosJiIJwqxTFCVYjq4oixNhJKopEKMEYcG3d/rkybzhdSfZNH
V21FF98kBz4jmaEKo0ERsQtVfR/7A5W6HNLV5sBM=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:from:to:subject:date:message-id:content-type
:content-transfer-encoding:mime-version; s=default; bh=Rp5npTcpa
S84P4Wd+geoQ2SElT4=; b=isIs1NOhhqgde5BhIhCci4AlWParLaC88p/ylLtU/
63grYJIhl+04JMbkgqe+XLrX5VQlqgFkh2znV1xsKh9EYCd1nz+sRqVvHEE53fW6
5U6PkA2A0my3lVq2MeMZYFGVbFrvGckzT2f2cVizacIQNaq9Xs++S5238Hs7wAnQ
c8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=2.4 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2
X-HELO: smtp-fr.alcatel-lucent.com
From: "Kertz, Denis (D)** CTR **" <d DOT kertz AT alcatel-lucent DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
Subject: RE: Unable to run excel via cron
Date: Fri, 26 Jun 2015 00:59:36 +0000
Message-ID: <883F2CBBC85A62419E181EB2F0ECF21F45DE9848@US70UWXCHMBA04.zam.alcatel-lucent.com>
MIME-Version: 1.0
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id t5Q100es006958

I'm not sure but I think Larry was saying the issue was that Excel by its nature is an interactive program and that was the crux of the problem, even though I was running Excel without any interactive input.  (And Larry wanted to emphasize this wasn't a cygwin problem per se - it was a problem with getting cygwin/cron to function within the windows structure.)

However, sometimes you get lucky even though you don't quite know what you are doing.  Having given up on being able to run Excel from a cron I started investigating running a bash script via the windows task scheduler (http://www.davidjnice.com/cygwin_scheduled_tasks.html).  A colleague of mine had already set up some Excel programs running from the task scheduler and I checked them out and noticed he ran them via a vbscript by creating a shell to run the Excel programs.  A light bulb went off and, guessing that a shell is by definition able to handle an interactive program like Excel, I ran this vbscript from a cron job (run with c:/Windows/System32/wscript.exe):

Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")
objShell.Run "C:\cygwin64\home\<login>\TestExcel.xls", 1, true
Set objShell = Nothing

This worked!  The cron ran the TestExcel.xls via WScript.Shell and this .xls saved itself (saveas) as a .htm file.  This demonstrated that an Excel program could be run and it could create a file.  This also worked with the cron set up to run either under cygserver or my cygwin login.

There was one wrinkle here.  The previous script that wouldn't run under Win7 was set up to initiate the Excel program and then terminate it.  This shell approach initiated the Excel program but left the Excel program still running.  I had to add an explicit 'Application.Quit' in my Excel macro to force the termination of Excel, a fairly minor change.

Thanks to all who helped me reach this solution.  Hopefully it may help others with a similar problem.

Denis

-------------------------------------------------------------------------------------------------------------------------
Andy Hall wrote:

I think Denis is saying Excel hangs even if it doesn't require user interaction. 
 I.e.  it runs some macros and exits.   On Win7 Pro, I was able to run the following 
.vbs script via the task scheduler and have it run the  "AddTimeInColumn" macro.
The resulting spreadsheet had the times the task was run column A.

Andy

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