PC Review


Reply
Thread Tools Rate Thread

Batch command file quits mysteriously

 
 
RichardOnRails
Guest
Posts: n/a
 
      9th Jul 2010
Hi,

I decided to create a batch file to build a RubyOnRails application
step-by-step. I want to take this approach so that I'd have a
reproducible build process.

After a couple of commands to switch to the required working
directory, the first substantive Rails command was invoked. It's a
command that's always worked reliably for me and I believe many Rails
programmers. Judging by its output, I believe it worked correctly
from this batch-file invocation. But the immediately following
command was not executed. I'd like to find out why.

Below is version stripped of most of the things relevant to this
problem: The Command Window output is provided also.

Thanks in Advance,
Richard

K:
cd K:\_Projects\Ruby\_Rails_Apps\_EIMS
if "%1" == "run" goto step1_run

:step1_run
rails RTS2 –d mysql
@echo RTS2 creation completed
goto remaining_steps

:remaing_steps
@echo ----
@ echo Beginning remainining steps
@ echo ---
ruby generate/scaffold Expense vendor:string description:string
category:string account:string amount:decimal mode:string
tran_date:date user_id:decimal

======== Command Window ======
C:\>GenerateRailsAppX run

C:\>K:

K:\>cd K:\_Projects\Ruby\_Rails_Apps\_EIMS

K:\_Projects\Ruby\_Rails_Apps\_EIMS>if "run" == "run" goto step1_run

K:\_Projects\Ruby\_Rails_Apps\_EIMS>rails RTS2 ûd mysql
exists
exists app/controllers
exists app/helpers
exists app/models
exists app/views/layouts
exists config/environments
exists config/initializers
[snip]
identical doc/README_FOR_APP
identical log/server.log
identical log/production.log
identical log/development.log
identical log/test.log

K:\_Projects\Ruby\_Rails_Apps\_EIMS>

NOTE: The echo command immediately following the Rails command never
displayed it's content.
 
Reply With Quote
 
 
 
 
Randem
Guest
Posts: n/a
 
      9th Jul 2010
Long time since I did batch programming but try this:

cmd /c rails RTS2 –d mysql

--
The Top Script Generator for Jordan Russell's Inno Setup -
http://www.randem.com/innoscript.html
Free Utilities and Code - http://www.randem.com/freesoftutil.html
"RichardOnRails" <(E-Mail Removed)> wrote in
message
news:b7201302-11a5-4382-b362-(E-Mail Removed)...
Hi,

I decided to create a batch file to build a RubyOnRails application
step-by-step. I want to take this approach so that I'd have a
reproducible build process.

After a couple of commands to switch to the required working
directory, the first substantive Rails command was invoked. It's a
command that's always worked reliably for me and I believe many Rails
programmers. Judging by its output, I believe it worked correctly
from this batch-file invocation. But the immediately following
command was not executed. I'd like to find out why.

Below is version stripped of most of the things relevant to this
problem: The Command Window output is provided also.

Thanks in Advance,
Richard

K:
cd K:\_Projects\Ruby\_Rails_Apps\_EIMS
if "%1" == "run" goto step1_run

:step1_run
rails RTS2 –d mysql
@echo RTS2 creation completed
goto remaining_steps

:remaing_steps
@echo ----
@ echo Beginning remainining steps
@ echo ---
ruby generate/scaffold Expense vendor:string description:string
category:string account:string amount:decimal mode:string
tran_date:date user_id:decimal

======== Command Window ======
C:\>GenerateRailsAppX run

C:\>K:

K:\>cd K:\_Projects\Ruby\_Rails_Apps\_EIMS

K:\_Projects\Ruby\_Rails_Apps\_EIMS>if "run" == "run" goto step1_run

K:\_Projects\Ruby\_Rails_Apps\_EIMS>rails RTS2 ûd mysql
exists
exists app/controllers
exists app/helpers
exists app/models
exists app/views/layouts
exists config/environments
exists config/initializers
[snip]
identical doc/README_FOR_APP
identical log/server.log
identical log/production.log
identical log/development.log
identical log/test.log

K:\_Projects\Ruby\_Rails_Apps\_EIMS>

NOTE: The echo command immediately following the Rails command never
displayed it's content.


 
Reply With Quote
 
Mike S
Guest
Posts: n/a
 
      9th Jul 2010
On 7/8/2010 6:02 PM, Randem wrote:
> Long time since I did batch programming but try this:
>
> cmd /c rails RTS2 –d mysql



What do you make of the fact that your command was:

RTS2 –d mysql

And the response was:

rails RTS2 ûd mysql

Do you need to use quotation marks, or is there some other way to invoke
the same flag?


 
Reply With Quote
 
Randem
Guest
Posts: n/a
 
      9th Jul 2010
Yes, try quotation marks

cmd /c "rails RTS2 -d mysql"

--
The Top Script Generator for Jordan Russell's Inno Setup -
http://www.randem.com/innoscript.html
Free Utilities and Code - http://www.randem.com/freesoftutil.html
"Mike S" <(E-Mail Removed)> wrote in message
news:i160b6$omq$(E-Mail Removed)...
> On 7/8/2010 6:02 PM, Randem wrote:
>> Long time since I did batch programming but try this:
>>
>> cmd /c rails RTS2 –d mysql

>
>
> What do you make of the fact that your command was:
>
> RTS2 –d mysql
>
> And the response was:
>
> rails RTS2 ûd mysql
>
> Do you need to use quotation marks, or is there some other way to invoke
> the same flag?
>
>



 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      9th Jul 2010


"RichardOnRails" <(E-Mail Removed)> wrote in
message
news:b7201302-11a5-4382-b362-(E-Mail Removed)...
> Hi,
>
> I decided to create a batch file to build a RubyOnRails application
> step-by-step. I want to take this approach so that I'd have a
> reproducible build process.
>
> After a couple of commands to switch to the required working
> directory, the first substantive Rails command was invoked. It's a
> command that's always worked reliably for me and I believe many Rails
> programmers. Judging by its output, I believe it worked correctly
> from this batch-file invocation. But the immediately following
> command was not executed. I'd like to find out why.
>
> Below is version stripped of most of the things relevant to this
> problem: The Command Window output is provided also.
>
> Thanks in Advance,
> Richard
>
> K:
> cd K:\_Projects\Ruby\_Rails_Apps\_EIMS
> if "%1" == "run" goto step1_run
>
> :step1_run
> rails RTS2 –d mysql
> @echo RTS2 creation completed
> goto remaining_steps
>
> :remaing_steps
> @echo ----
> @ echo Beginning remainining steps
> @ echo ---
> ruby generate/scaffold Expense vendor:string description:string
> category:string account:string amount:decimal mode:string
> tran_date:date user_id:decimal
>
> ======== Command Window ======
> C:\>GenerateRailsAppX run
>
> C:\>K:
>
> K:\>cd K:\_Projects\Ruby\_Rails_Apps\_EIMS
>
> K:\_Projects\Ruby\_Rails_Apps\_EIMS>if "run" == "run" goto step1_run
>
> K:\_Projects\Ruby\_Rails_Apps\_EIMS>rails RTS2 ûd mysql
> exists
> exists app/controllers
> exists app/helpers
> exists app/models
> exists app/views/layouts
> exists config/environments
> exists config/initializers
> [snip]
> identical doc/README_FOR_APP
> identical log/server.log
> identical log/production.log
> identical log/development.log
> identical log/test.log
>
> K:\_Projects\Ruby\_Rails_Apps\_EIMS>
>
> NOTE: The echo command immediately following the Rails command never
> displayed it's content.


Some executables return control to the invoking batch file immediately after
being invoked. Others only do it after they themselves finish. It depends on
how they are written. Rails.exe appears to belong to the second class. You
can get around the issue like so:

start /b rails RTS2 –d mysql

A more robust approach would look like this (because it specifies the full
path to rails.exe):

start /b "Ruby on Rails" /d "c:\Program Files\Rails" rails.exe RTS2 –d
mysql



 
Reply With Quote
 
RichardOnRails
Guest
Posts: n/a
 
      9th Jul 2010
Great responses -- Thank you, all.

> Randem: cmd /c my-command -- that solved most of my problem


> Mike S (with eagle eyes) asked "What about RTS2 –d mysql => rails RTS2 ûd mysql"


My first thought was "That's a German character".
(I've got German keyboard translator on my system, but haven't used it
recently).
Then I realized the diacritical mark over the "u" was carat and not
two dots, so it's not German.

My second thought was "Enclose my command in quotes", to no avail.
Trying single quotes was even worse

> Pegasys: "start /b rails RTS2 –d mysql " ran the command as well as "cmd /c",

but it had the same deficiency, i.e. converting the "-d" switch into u-
hat followed by d.
That is the remaining outstanding issue for me

Again, thank you all.

Best wishes,
Richard
 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      9th Jul 2010


"RichardOnRails" <(E-Mail Removed)> wrote in
message
news:18a4d385-0a8e-448c-b1ce-(E-Mail Removed)...
> Great responses -- Thank you, all.
>
>> Randem: cmd /c my-command -- that solved most of my problem

>
>> Mike S (with eagle eyes) asked "What about RTS2 –d mysql => rails RTS2
>> ûd mysql"

>
> My first thought was "That's a German character".
> (I've got German keyboard translator on my system, but haven't used it
> recently).
> Then I realized the diacritical mark over the "u" was carat and not
> two dots, so it's not German.
>
> My second thought was "Enclose my command in quotes", to no avail.
> Trying single quotes was even worse
>
>> Pegasys: "start /b rails RTS2 –d mysql " ran the command as well as "cmd
>> /c",

> but it had the same deficiency, i.e. converting the "-d" switch into u-
> hat followed by d.
> That is the remaining outstanding issue for me
>
> Again, thank you all.
>
> Best wishes,
> Richard


While I can see the caret symbol in your post, I have a very poor
understanding where it comes from, where it occurs and how it finds its way
into your batch file. Please elaborate.

 
Reply With Quote
 
RichardOnRails
Guest
Posts: n/a
 
      9th Jul 2010
On Jul 9, 2:51*pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
> messagenews:18a4d385-0a8e-448c-b1ce-(E-Mail Removed)..com...
>
>
>
> > Great responses -- Thank you, all.

>
> >> Randem: cmd /c my-command -- that solved most of my problem

>
> >> Mike S (with eagle eyes) asked "What about RTS2 –d mysql *=> rails RTS2
> >> ûd mysql"

>
> > My first thought was "That's a German character".
> > (I've got German keyboard translator on my system, but haven't used it
> > recently).
> > Then I realized the diacritical mark over the "u" was carat and not
> > two dots, so it's not German.

>
> > My second thought was "Enclose my command in quotes", to no avail.
> > Trying single quotes was even worse

>
> >> Pegasys: "start /b rails RTS2 –d mysql " ran the command as well as "cmd
> >> /c",

> > but it had the same deficiency, i.e. converting the "-d" switch into u-
> > hat followed by d.
> > That is the remaining outstanding issue for me

>
> > Again, *thank you all.

>
> > Best wishes,
> > Richard

>
> While I can see the caret symbol in your post, I have a very poor
> understanding where it comes from, where it occurs and how it finds its way
> into your batch file. Please elaborate.


Thanks for taking an additional look at this anomaly. Here's a vastly
simplified version of the script and the result:

K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools\KeyTools>type
GenerateRailsAppX.bat
rails RTS2 ûd mysql

K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools
\KeyTools>GenerateRailsAppX.bat

K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools\KeyTools>rails RTS2 ûd mysql
exists
exists app/controllers
exists app/helpers
exists app/models
[snip]

Best wishes,
Richard
 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      9th Jul 2010



"RichardOnRails" <(E-Mail Removed)> wrote in
message
news:f5c29ea8-4d87-4459-ba29-(E-Mail Removed)...
> On Jul 9, 2:51 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
>> "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
>> messagenews:18a4d385-0a8e-448c-b1ce-(E-Mail Removed)...
>>
>>
>>
>> > Great responses -- Thank you, all.

>>
>> >> Randem: cmd /c my-command -- that solved most of my problem

>>
>> >> Mike S (with eagle eyes) asked "What about RTS2 –d mysql => rails
>> >> RTS2
>> >> ûd mysql"

>>
>> > My first thought was "That's a German character".
>> > (I've got German keyboard translator on my system, but haven't used it
>> > recently).
>> > Then I realized the diacritical mark over the "u" was carat and not
>> > two dots, so it's not German.

>>
>> > My second thought was "Enclose my command in quotes", to no avail.
>> > Trying single quotes was even worse

>>
>> >> Pegasys: "start /b rails RTS2 –d mysql " ran the command as well as
>> >> "cmd
>> >> /c",
>> > but it had the same deficiency, i.e. converting the "-d" switch into u-
>> > hat followed by d.
>> > That is the remaining outstanding issue for me

>>
>> > Again, thank you all.

>>
>> > Best wishes,
>> > Richard

>>
>> While I can see the caret symbol in your post, I have a very poor
>> understanding where it comes from, where it occurs and how it finds its
>> way
>> into your batch file. Please elaborate.

>
> Thanks for taking an additional look at this anomaly. Here's a vastly
> simplified version of the script and the result:
>
> K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools\KeyTools>type
> GenerateRailsAppX.bat
> rails RTS2 ûd mysql
>
> K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools
> \KeyTools>GenerateRailsAppX.bat
>
> K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools\KeyTools>rails RTS2 ûd mysql
> exists
> exists app/controllers
> exists app/helpers
> exists app/models
> [snip]
>
> Best wishes,
> Richard


I don't know anything about rails.exe but my initial reaction would be:
1. Check the permissible command line switches for rails.exe
2. Modify the batch file accordingly. The problem line should probably read
rails RTS2 /d mysql

 
Reply With Quote
 
RichardOnRails
Guest
Posts: n/a
 
      9th Jul 2010
On Jul 9, 5:37*pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
> messagenews:f5c29ea8-4d87-4459-ba29-(E-Mail Removed)...
>
>
>
> > On Jul 9, 2:51 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
> >> "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
> >> messagenews:18a4d385-0a8e-448c-b1ce-(E-Mail Removed)...

>
> >> > Great responses -- Thank you, all.

>
> >> >> Randem: cmd /c my-command -- that solved most of my problem

>
> >> >> Mike S (with eagle eyes) asked "What about RTS2 –d mysql *=> rails
> >> >> RTS2
> >> >> ûd mysql"

>
> >> > My first thought was "That's a German character".
> >> > (I've got German keyboard translator on my system, but haven't used it
> >> > recently).
> >> > Then I realized the diacritical mark over the "u" was carat and not
> >> > two dots, so it's not German.

>
> >> > My second thought was "Enclose my command in quotes", to no avail.
> >> > Trying single quotes was even worse

>
> >> >> Pegasys: "start /b rails RTS2 –d mysql " ran the command as well as
> >> >> "cmd
> >> >> /c",
> >> > but it had the same deficiency, i.e. converting the "-d" switch intou-
> >> > hat followed by d.
> >> > That is the remaining outstanding issue for me

>
> >> > Again, *thank you all.

>
> >> > Best wishes,
> >> > Richard

>
> >> While I can see the caret symbol in your post, I have a very poor
> >> understanding where it comes from, where it occurs and how it finds its
> >> way
> >> into your batch file. Please elaborate.

>
> > Thanks for taking an additional look at this anomaly. *Here's a vastly
> > simplified version of the script and the result:

>
> > K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools\KeyTools>type
> > GenerateRailsAppX.bat
> > rails RTS2 ûd mysql

>
> > K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools
> > \KeyTools>GenerateRailsAppX.bat

>
> > K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools\KeyTools>rails RTS2 ûd mysql
> > * * *exists
> > * * *exists *app/controllers
> > * * *exists *app/helpers
> > * * *exists *app/models
> > [snip]

>
> > Best wishes,
> > Richard

>
> I don't know anything about rails.exe but my initial reaction would be:
> 1. Check the permissible command line switches for rails.exe
> 2. Modify the batch file accordingly. The problem line should probably read
> * *rails RTS2 /d mysql


Thanks for your suggestions. However, the command I'm trying to
invoke through the batch file is shown below entered manually in a
command window, just as I've done many times:

K:\_Projects\Ruby\_Rails_Apps\_EIMS>rails RTS2 -d mysql
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
[snip]

BTW, this command causes:
1. The creation of an EIMS sub-directory named RTS2.
2, Creation and population of a RTS2 subdirectories
3. This code can be passed to a web-server, thus creating a website
4. When a browser properly invokes this website, its various pages
will be presented, etc.
Finally, the -b switch tell the generated Rails app to use MySQL as
its database server, rather than the current default, SQLite3.

I'm pretty sure the problem is some flaky setting in my computer, but
I I have no idea how eliminate it short of wiping out WinXP and re-
installing it and its service packs. That's too gruesome a prospect
for me. So I'm going to try to get Rake (a Ruby/Rails "make" system)
which is more appropriate for what I'm doing anyway.

Best wishes,
Richard
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch file works in command line but not as a batch Danger Windows XP General 7 5th Feb 2008 04:50 PM
FOR Command in a batch file pestrue@gmail.com Windows XP General 1 16th Feb 2007 06:13 PM
Net command from a batch file Dennis Windows XP General 0 20th Sep 2004 09:22 PM
Batch file command Windows XP General 2 14th Aug 2004 12:30 AM
Re: batch file command Torgeir Bakken (MVP) Microsoft Windows 2000 CMD Promt 0 23rd Sep 2003 02:29 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:27 AM.