delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/11/07/16:48:39

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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
q=dns; s=default; b=Djk8kpfM083oWyNNcEzu1and/OPIWp6uipnr50K6WdT
1IJko7AkTleGmwUgOQ9VWY0GHjrHFN/s49adFuFjrO0RRcfE2j3DWZ00uCmHQJZJ
jeZdA73lKmbuR4EkUbd0OW4gGfAOCdnw+8GmJ4WmjqrZOuLHqfUP4E+nWG+mFk2A
=
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:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
s=default; bh=lsrg9v1FHehunbT5IkeqbhdpqI4=; b=mkj7/q2AI6eeshaw/
sBfAe0XuCk7qbwmt+8dJYuYDJi1UhNF1TgOMLQujlRXtKfyamtrb03wCjLJNDsZB
1cOVwB0ER9SHdkXQW17RT5wrwwWhnZrFDLyDRAKNnigasDDCeZuAy0s8Hhg9sKbg
CVYM12np1opqMj3DXAfAmbc2is=
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.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2
X-HELO: mail-oi0-f43.google.com
X-Received: by 10.182.102.37 with SMTP id fl5mr12058755obb.24.1415396898340; Fri, 07 Nov 2014 13:48:18 -0800 (PST)
Message-ID: <545D3E21.2030306@bopp.net>
Date: Fri, 07 Nov 2014 15:48:17 -0600
From: Jeremy Bopp <jeremy AT bopp DOT net>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: how to embed shell script within a .BAT file
References: <0D835E9B9CD07F40A48423F80D3B5A702E8379F0 AT USA7109MB022 DOT na DOT xerox DOT net>
In-Reply-To: <0D835E9B9CD07F40A48423F80D3B5A702E8379F0@USA7109MB022.na.xerox.net>
X-IsSubscribed: yes

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


-Jeremy

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