delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/02/19/17:01:36

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
Message-Id: <5.2.0.9.2.20030219135643.02c2eb50@pop3.cris.com>
X-Sender: rrschulz AT pop3 DOT cris DOT com
Date: Wed, 19 Feb 2003 14:01:50 -0800
To: cygwin AT cygwin DOT com
From: Randall R Schulz <rrschulz AT cris DOT com>
Subject: Re: Win 2000 : Open Files With Word & Excel From The Command
Line
In-Reply-To: <b30tqa$1gb$1@main.gmane.org>
References: <b2kdhh$jeb$1 AT main DOT gmane DOT org>
<b2kdhh$jeb$1 AT main DOT gmane DOT org>
Mime-Version: 1.0

Steve,

If you have or are willing to install the cygutils package, then 
cygstart is indeed the preferred way to deal with this general problem.

However so that you'll be able to do comparable scripting when cygstart 
isn't an option, I'll point out where you went wrong--it's all 
erroneous BASH syntax. See below.


At 13:46 2003-02-19, Steve wrote:
>Hi;
>
>I managed to get my script "word" to open up word with the path I 
>typed on the command line in cygwin.
>
>I am having trouble getting the same to work with excel.
>
>I am win 2000 and using cygwin.
>
>I made a script in /usr/local/bin called "excel".
>
>The script will boot up excel, but not with the file I specified.  I 
>get error messages saying that the file does not exist.  Between the 
>"===" lines are the different contests I have tried for my "excel" script:
>
>
>version 1
>============================================================
>exec "c:/Program Files/Microsoft Office/Office/EXCEL.EXE" "cygpath -w $1"

You're not invoking cygpath here, you're just creating a single 
argument to EXCEL.EXE that is composed of "cygpath -w " plus whatever 
was argument one to the script invocation.

This is what you want instead:

exec "c:/Program Files/Microsoft Office/Office/EXCEL.EXE" "$(cygpath -w $1)".


>===========================================================
>version 2
>exec "c:/Program Files/Microsoft Office/Office/EXCEL.EXE" "@&"

In order to get each argument individually quoted (exactly what's 
called for in this case), the BASH syntax is:

exec "c:/Program Files/Microsoft Office/Office/EXCEL.EXE" "$@"

This a special case of the general BASH array referencing syntax, which 
is byzzantine. Please refer to the BASH documentation see it in its full glory.


>Usage:
>
>$ word /path/to/file.xls
>
>Any ideas would be appreciated
>
>Thanks
>
>Steve


Randall Schulz 


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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