public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Run bash script in cmd with cygwin
@ 2013-09-24 21:49 Ulrich Pogson
  2013-09-25  4:32 ` Matt D.
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Ulrich Pogson @ 2013-09-24 21:49 UTC (permalink / raw)
  To: cygwin

Hello

I would like to run this script `for file in `find . -name "*.po"` ;
do msgfmt -o ${file/.po/.mo} $file ; done` in windows cmd. The script
need to run in a different folder. I have been able to run it though
cygwin but want to integrate it with another system where it will be
run through cmd.

C:\cygwin\bin
D:\path\to\dir

How can I do this?

Thanks.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
  2013-09-24 21:49 Run bash script in cmd with cygwin Ulrich Pogson
@ 2013-09-25  4:32 ` Matt D.
  2013-09-25  6:49 ` Ulrich Pogson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Matt D. @ 2013-09-25  4:32 UTC (permalink / raw)
  To: cygwin

Try adding this to your script:

cd /cygdrive/d/path/to/dir;`for file..


Matt D.

On 9/24/2013 5:43 PM, Ulrich Pogson wrote:
> Hello
>
> I would like to run this script `for file in `find . -name "*.po"` ;
> do msgfmt -o ${file/.po/.mo} $file ; done` in windows cmd. The script
> need to run in a different folder. I have been able to run it though
> cygwin but want to integrate it with another system where it will be
> run through cmd.
>
> C:\cygwin\bin
> D:\path\to\dir
>
> How can I do this?
>
> Thanks.
>
> --
> 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
>
>
>

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
  2013-09-24 21:49 Run bash script in cmd with cygwin Ulrich Pogson
  2013-09-25  4:32 ` Matt D.
@ 2013-09-25  6:49 ` Ulrich Pogson
  2013-09-25 14:25   ` Warren Young
  2013-09-25 14:12 ` Warren Young
  2013-09-25 18:31 ` Andrey Repin
  3 siblings, 1 reply; 9+ messages in thread
From: Ulrich Pogson @ 2013-09-25  6:49 UTC (permalink / raw)
  To: cygwin

Thanks Matt, after try everything I could not get it to work. Could
you give me the whole code that I could enter in cmd that would run
cygwin and then run the script?

On 24 September 2013 23:43, Ulrich Pogson <grapplerulrich@gmail.com> wrote:
> Hello
>
> I would like to run this script `for file in `find . -name "*.po"` ;
> do msgfmt -o ${file/.po/.mo} $file ; done` in windows cmd. The script
> need to run in a different folder. I have been able to run it though
> cygwin but want to integrate it with another system where it will be
> run through cmd.
>
> C:\cygwin\bin
> D:\path\to\dir
>
> How can I do this?
>
> Thanks.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
  2013-09-24 21:49 Run bash script in cmd with cygwin Ulrich Pogson
  2013-09-25  4:32 ` Matt D.
  2013-09-25  6:49 ` Ulrich Pogson
@ 2013-09-25 14:12 ` Warren Young
  2013-09-25 18:31 ` Andrey Repin
  3 siblings, 0 replies; 9+ messages in thread
From: Warren Young @ 2013-09-25 14:12 UTC (permalink / raw)
  To: Cygwin-L

On 9/24/2013 15:43, Ulrich Pogson wrote:
>
> I would like to run this script `for file in `find . -name "*.po"` ;
> do msgfmt -o ${file/.po/.mo} $file ; done` in windows cmd.

What exactly do you mean by "in windows cmd"?

If you're trying to translate this script into cmd.exe's "batch" 
language, it's not going to be an easy translation because batch is 
about as impoverished as programming languages get, and you're using 
some pretty advanced Bash features here.  Pattern substitution in 
variable interpolation and command output substitution don't even exist 
in cmd.exe's batch language.  You'd have to fake it with temporary files 
or some other hack like that.

If you're just trying to get this bit of Bash code to run from cmd.exe 
but you can still have Bash installed, the solution is fairly simple:

     d:\path\to\dir> bash -c "for file in..."

The trickiest part is handling all the quoting, so it gets to bash.exe 
correctly.  It might be simpler to put this into a script file so you 
can say "bash -c /path/to/my/script.sh" instead of depending on cmd.exe 
to get quoting right.

You also have to handle the PATH issues.

The simplest option is to make sure the Cygwin bin directory is at the 
start of the PATH while in cmd.exe.

If you can't do that, then you end up with something fairly ugly:

    c:\> c:\cygwin\bin\bash -c "for file in `/bin/find..."

Note that you have to give explicit path names in both DOS and POSIX 
forms here for the different parts.  You have a special trap here 
because Windows provides a find.exe, and it isn't at all the same thing 
as Cygwin's find.exe.

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
  2013-09-25  6:49 ` Ulrich Pogson
@ 2013-09-25 14:25   ` Warren Young
  0 siblings, 0 replies; 9+ messages in thread
From: Warren Young @ 2013-09-25 14:25 UTC (permalink / raw)
  To: Cygwin-L

On 9/25/2013 00:33, Ulrich Pogson wrote:
> after try everything I could not get it to work.

If my other post to this thread doesn't help, post the errors you get. 
You're making us guess what is wrong with "everything", and we don't 
know what's wrong with "everything". :)

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
  2013-09-24 21:49 Run bash script in cmd with cygwin Ulrich Pogson
                   ` (2 preceding siblings ...)
  2013-09-25 14:12 ` Warren Young
@ 2013-09-25 18:31 ` Andrey Repin
  2013-09-25 21:39   ` Ulrich Pogson
  3 siblings, 1 reply; 9+ messages in thread
From: Andrey Repin @ 2013-09-25 18:31 UTC (permalink / raw)
  To: Ulrich Pogson, cygwin

Greetings, Ulrich Pogson!

> I would like to run this script `for file in `find . -name "*.po"` ;
> do msgfmt -o ${file/.po/.mo} $file ; done` in windows cmd.

I think you mean "command line" and not a "script".
This is not realistically possible. Windows CMD do not have as straightforward
quoting and escaping rules, as you might wish for it to have.
Your only safe bet is to actually write a script and execute it from cmd, when
need.

> The script need to run in a different folder. I have been able to run it
> though cygwin but want to integrate it with another system where it will be
> run through cmd.

> C:\cygwin\bin
> D:\path\to\dir

> How can I do this?

The association:

FTYPE unixshell.script="%CygwinDir%\bin\env.exe" "%1" %*
ASSOC .sh=unixshell.script

then your find-poo.sh

#! /bin/sh
for file in $(find . -name "*.po")
  do msgfmt -o ${file/.po/.mo} $file
done


--
WBR,
Andrey Repin (anrdaemon@yandex.ru) 25.09.2013, <21:05>

Sorry for my terrible english...


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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
  2013-09-25 18:31 ` Andrey Repin
@ 2013-09-25 21:39   ` Ulrich Pogson
       [not found]     ` <1009095134.20130926013417@mtu-net.ru>
  2013-09-27  2:54     ` Larry Hall (Cygwin)
  0 siblings, 2 replies; 9+ messages in thread
From: Ulrich Pogson @ 2013-09-25 21:39 UTC (permalink / raw)
  To: Andrey Repin

Thanks for your help

I got it to work with this line.
I: & cd I:\Work\GitHub\responsive\languages & c:\cygwin64\bin\bash -c
\cygdrive\i\Work\GitHub\responsive\languages\potomo.sh
and this file.
https://gist.github.com/grappler/6704735

On 25 September 2013 19:16, Andrey Repin <anrdaemon@yandex.ru> wrote:
> Greetings, Ulrich Pogson!
>
>> I would like to run this script `for file in `find . -name "*.po"` ;
>> do msgfmt -o ${file/.po/.mo} $file ; done` in windows cmd.
>
> I think you mean "command line" and not a "script".
> This is not realistically possible. Windows CMD do not have as straightforward
> quoting and escaping rules, as you might wish for it to have.
> Your only safe bet is to actually write a script and execute it from cmd, when
> need.
>
>> The script need to run in a different folder. I have been able to run it
>> though cygwin but want to integrate it with another system where it will be
>> run through cmd.
>
>> C:\cygwin\bin
>> D:\path\to\dir
>
>> How can I do this?
>
> The association:
>
> FTYPE unixshell.script="%CygwinDir%\bin\env.exe" "%1" %*
> ASSOC .sh=unixshell.script
>
> then your find-poo.sh
>
> #! /bin/sh
> for file in $(find . -name "*.po")
>   do msgfmt -o ${file/.po/.mo} $file
> done
>
>
> --
> WBR,
> Andrey Repin (anrdaemon@yandex.ru) 25.09.2013, <21:05>
>
> Sorry for my terrible english...
>

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
       [not found]     ` <1009095134.20130926013417@mtu-net.ru>
@ 2013-09-25 22:17       ` Ulrich Pogson
  0 siblings, 0 replies; 9+ messages in thread
From: Ulrich Pogson @ 2013-09-25 22:17 UTC (permalink / raw)
  To: Andrey Repin

Hi Andrey,

I am sorry I don't fully understand. I am a beginner try to get
something to work. What I am doing is that after pulling the .po I
need to create a .mo file.
https://github.com/AtelierConvivialite/webtranslateit/blob/master/examples/.wti#L11

On 25 September 2013 23:34, Andrey Repin <anrdaemon@yandex.ru> wrote:
> Greetings, Ulrich Pogson!
>
>>>> I would like to run this script `for file in `find . -name "*.po"` ;
>>>> do msgfmt -o ${file/.po/.mo} $file ; done` in windows cmd.
>>>
>>> I think you mean "command line" and not a "script".
>>> This is not realistically possible. Windows CMD do not have as straightforward
>>> quoting and escaping rules, as you might wish for it to have.
>>> Your only safe bet is to actually write a script and execute it from cmd, when
>>> need.
>>>
>>>> The script need to run in a different folder. I have been able to run it
>>>> though cygwin but want to integrate it with another system where it will be
>>>> run through cmd.
>>>
>>>> C:\cygwin\bin
>>>> D:\path\to\dir
>>>
>>>> How can I do this?
>>>
>>> The association:
>>>
>>> FTYPE unixshell.script="%CygwinDir%\bin\env.exe" "%1" %*
>>> ASSOC .sh=unixshell.script
>>>
>>> then your find-poo.sh
>>>
>>> #! /bin/sh
>>> for file in $(find . -name "*.po")
>>>   do msgfmt -o ${file/.po/.mo} $file
>>> done
>
>> Thanks for your help
>
>> I got it to work with this line.
>> I: & cd I:\Work\GitHub\responsive\languages & c:\cygwin64\bin\bash -c
>> \cygdrive\i\Work\GitHub\responsive\languages\potomo.sh
>> and this file.
>> https://gist.github.com/grappler/6704735
>
> First of all, don't http://cygwin.com/acronyms/#TOFU
> Just don't.
> Second, I don't see, why you waste time starting bash manually.
>
>
> --
> WBR,
> Andrey Repin (anrdaemon@yandex.ru) 26.09.2013, <01:32>
>
> Sorry for my terrible english...
>

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Run bash script in cmd with cygwin
  2013-09-25 21:39   ` Ulrich Pogson
       [not found]     ` <1009095134.20130926013417@mtu-net.ru>
@ 2013-09-27  2:54     ` Larry Hall (Cygwin)
  1 sibling, 0 replies; 9+ messages in thread
From: Larry Hall (Cygwin) @ 2013-09-27  2:54 UTC (permalink / raw)
  To: cygwin

On 9/25/2013 5:25 PM, Ulrich Pogson wrote:
> Thanks for your help
>
> I got it to work with this line.
> I: & cd I:\Work\GitHub\responsive\languages & c:\cygwin64\bin\bash -c
> \cygdrive\i\Work\GitHub\responsive\languages\potomo.sh
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Cygwin prefers POSIX paths and separators.  You should prefer / over \
for this final path.

-- 
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-09-26 18:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-24 21:49 Run bash script in cmd with cygwin Ulrich Pogson
2013-09-25  4:32 ` Matt D.
2013-09-25  6:49 ` Ulrich Pogson
2013-09-25 14:25   ` Warren Young
2013-09-25 14:12 ` Warren Young
2013-09-25 18:31 ` Andrey Repin
2013-09-25 21:39   ` Ulrich Pogson
     [not found]     ` <1009095134.20130926013417@mtu-net.ru>
2013-09-25 22:17       ` Ulrich Pogson
2013-09-27  2:54     ` Larry Hall (Cygwin)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).