From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18786 invoked by alias); 11 Nov 2014 16:12:33 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 18774 invoked by uid 89); 11 Nov 2014 16:12:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: USA7109MR001.ACS-INC.COM Received: from usa7109mr001.acs-inc.com (HELO USA7109MR001.ACS-INC.COM) (63.101.151.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 11 Nov 2014 16:12:31 +0000 Received: from usa7109ht004.na.xerox.net ([13.41.230.30]) by USA7109MR001.ACS-INC.COM with ESMTP/TLS/AES128-SHA; 11 Nov 2014 10:10:17 -0600 Received: from USA7109MB022.na.xerox.net ([169.254.6.136]) by USA7109HT004.na.xerox.net ([13.41.230.30]) with mapi id 14.03.0174.001; Tue, 11 Nov 2014 10:10:15 -0600 From: "Nellis, Kenneth" To: "cygwin@cygwin.com" Subject: RE: how to embed shell script within a .BAT file Date: Tue, 11 Nov 2014 16:12:00 -0000 Message-ID: <0D835E9B9CD07F40A48423F80D3B5A702E839DB4@USA7109MB022.na.xerox.net> References: <87bnoforlc.fsf@Rainer.invalid> In-Reply-To: <87bnoforlc.fsf@Rainer.invalid> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2014-11/txt/msg00235.txt.bz2 > From: Achim Gratz >=20 > Nellis, Kenneth writes: > > Jeremy's solution is closest to what I was looking for; however I need > > it to work from a networked, non-drive-mapped folder. > > (CMD.EXE doesn't like UNC paths.) I hadn't realized that I could pipe > > a script into bash. >=20 > The solution to the UNC path problem is to put something >=20 > PUSHD %~dp0 >=20 > near the beginning of the script. That is if you really want to have .bat > files and click on them in Explorer. Associating the shell scripts > properly so that Explorer will hand them to Cygwin sounds like a better > solution to me. BTW, works great! Here's the completed .BAT file preface with added error handling so the CMD window doesn't auto-close if the bash code exits with an error. @echo off set PATH=3DC:\cygwin64\bin;%PATH% PUSHD %~dp0 type %0 | sed "0,/^---BASH SCRIPT FOLLOWS---/ d; s/\r*$//" | bash if errorlevel 1 pause exit ---BASH SCRIPT FOLLOWS--- ... I'll pursue associating a shell script with a file type when I have more time. --Ken Nellis -- 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