Batch command file quits mysteriously

  • Thread starter Thread starter RichardOnRails
  • Start date Start date
R

RichardOnRails

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.
 
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
message
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.
 
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?
 
message
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
 
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
 
message
Great responses -- Thank you, all.



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

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







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










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
 
message

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
 
On 7/9/2010 3:27 PM, RichardOnRails wrote:
K:\_Projects\Ruby\_Rails_Apps\_EIMS>rails RTS2 -d mysql
[snip]

I'm not sure if this is due the my (Thuncerbird) newsreader changing the
dash that you used to a different font or not but when I copy your dash
symbol into a text editor

then type a dash symbol below it
-
and enlarge the font to 72 or greater it's clear the symbols are not the
same. To be clear, I am typing the lower case key just to the right of
the 0 (zero) key above the O and P keys at the top right of the
keyboard. Is that the one you're using?

Maybe it's a charset issue? I believe you pick the default charset in
Control Panel > Regional and Language Options, under the Advanced tab

Mike
 
Problem solved!!

Thanks Pegasys & Mike S. for hanging in there with me. When I looked
at my command in Notepad, I saw:
rails RTS2 –d mysql

But when I entered in a Command window: Type GenerateRailsAppX.bat,
I saw:
rails RTS2 ûd mysql

Now I realized rails, RTS2, mysql were all irrelevent -- the problem
was with the -b itself.
So I added a line of dashed characters via Notepad and listed it in
the command window:

K:\_Projects\Ruby\_Rails_Apps\_EIMS\Tools\KeyTools>type Gen*x.bat
[snip]
rails RTS2 ûd mysql
:-a -b -c -d -e

So, clearly, there''s something wrong with the dash in the first line.
Viewed carefully in Notepad, it became clear that the dash before the
first d was larger than the next d's.
Voila! I changed it and problem solved.
BTW, I created the original GenerateRailsApp.bat using the IDE
"SciTE". I'll be more careful in the future.

Thanks one and all,
Richard
 
Back
Top