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:references :in-reply-to:content-type:content-transfer-encoding :mime-version; q=dns; s=default; b=xSevk89wupRJVth1+GDWBea1vzBUv yFudyOU4WUzqPVJoaTiBoKNmRsQmKgZ5x+R/DPQXDA+k/TXSiZ0dolKeijlZl2sK vYiVFNyI7X42rdmhn+PLdKIYY0utevPTNNX0bAljBU6OWG0W/GO7KfSK2cwxMRdU AieVVp5+KdBxtw= 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:references :in-reply-to:content-type:content-transfer-encoding :mime-version; s=default; bh=Ylu6X6ainbrEeHwzo3BfWPUvnJI=; b=yZQ GhJ0odFgLcLshfjNtRitOt5fOScM80VGTrPfR4wMAnQw5aWRBbxZwULGiiVRMhvm bblkrN/TVbethWd81Is/D9NBC4x4ljcVJPO4c0ps+2uOfEVC6skfajDqWS/NmSG2 jboiMFbXzLmMnQXlyowVqqGKoUOQ9ZjnEtWLQKF8= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=-0.2 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: usa7109mr007.acs-inc.com From: "Nellis, Kenneth" To: "cygwin AT cygwin DOT com" Subject: RE: how to embed shell script within a .BAT file Date: Mon, 10 Nov 2014 14:49:09 +0000 Message-ID: <0D835E9B9CD07F40A48423F80D3B5A702E839BB9@USA7109MB022.na.xerox.net> References: <545D3E21 DOT 2030306 AT bopp DOT net> In-Reply-To: <545D3E21.2030306@bopp.net> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id sAAEnaY5032732 > From: Jeremy Bopp > > On 11/07/2014 03:26 PM, Nellis, Kenneth wrote: > > I'm tired of creating pairs of script files: a clickable .BAT file to > > invoke my shell script and then my shell script to do the actual work. > > I was wondering if any of the geniuses on this list have come up with > > a way to embed a shell script inside a clickable .BAT file. > Something like this might do. It assumes you know the path to the Cygwin > bin directory. Passing in arguments would be a bit more work and would > probably be somewhat limited unless you have a small number of possible > arguments. > > FYI, I don't have a Windows system readily available anymore, so this is > untested. > > Shelly.bat: > > @echo off > > rem Put Cygwin bin directory into PATH > set PATH=C:\cygwin\bin;%PATH% > > type %0 | sed "0,/^---BASH SCRIPT FOLLOWS---/ d; s/\r*$//" | bash > goto :eof > > ---BASH SCRIPT FOLLOWS--- > echo $SHELL is alive > ^Z Thanx to Jeremy, Andrey, and the others who responded. 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. Andrey also suggested something that allows Windows-clickable script files, a strict requirement, bypassing the stated, but unnecessary requirement that it be a .BAT file, by associating a file type with bash. This would bypass the UNC issue, so may end up being the best solution for me. --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