1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Batch command file quits mysteriously

Discussion in 'Windows XP' started by RichardOnRails, Jul 8, 2010.

  1. RichardOnRails

    RichardOnRails Flightless Bird

    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.
     
  2. Randem

    Randem Flightless Bird

    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" <RichardDummyMailbox58407@USComputerGurus.com> wrote in
    message
    news:b7201302-11a5-4382-b362-546dd21ce2c5@d16g2000yqb.googlegroups.com...
    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.
     
  3. Mike S

    Mike S Flightless Bird

    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?
     
  4. Randem

    Randem Flightless Bird

    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" <mscir@yahoo.com> wrote in message
    news:i160b6$omq$1@news.eternal-september.org...
    > 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?
    >
    >
     
  5. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    "RichardOnRails" <RichardDummyMailbox58407@USComputerGurus.com> wrote in
    message
    news:b7201302-11a5-4382-b362-546dd21ce2c5@d16g2000yqb.googlegroups.com...
    > 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
     
  6. RichardOnRails

    RichardOnRails Flightless Bird

    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
     
  7. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    "RichardOnRails" <RichardDummyMailbox58407@USComputerGurus.com> wrote in
    message
    news:18a4d385-0a8e-448c-b1ce-1f7a36cb3c1f@k39g2000yqb.googlegroups.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.
     
  8. RichardOnRails

    RichardOnRails Flightless Bird

    On Jul 9, 2:51 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
    > "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
    > messagenews:18a4d385-0a8e-448c-b1ce-1f7a36cb3c1f@k39g2000yqb.googlegroups..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
     
  9. Pegasus [MVP]

    Pegasus [MVP] Flightless Bird

    "RichardOnRails" <RichardDummyMailbox58407@USComputerGurus.com> wrote in
    message
    news:f5c29ea8-4d87-4459-ba29-85554f9cfebb@5g2000yqz.googlegroups.com...
    > On Jul 9, 2:51 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
    >> "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
    >> messagenews:18a4d385-0a8e-448c-b1ce-1f7a36cb3c1f@k39g2000yqb.googlegroups.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


    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
     
  10. RichardOnRails

    RichardOnRails Flightless Bird

    On Jul 9, 5:37 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
    > "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
    > messagenews:f5c29ea8-4d87-4459-ba29-85554f9cfebb@5g2000yqz.googlegroups.com...
    >
    >
    >
    > > On Jul 9, 2:51 pm, "Pegasus [MVP]" <n...@microsoft.com> wrote:
    > >> "RichardOnRails" <RichardDummyMailbox58...@USComputerGurus.com> wrote in
    > >> messagenews:18a4d385-0a8e-448c-b1ce-1f7a36cb3c1f@k39g2000yqb.googlegroups.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 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
     
  11. Mike S

    Mike S Flightless Bird

    On 7/9/2010 3:27 PM, RichardOnRails wrote:
    <snip>
    >>>>>> Mike S 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
    >>>> 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.

    <snip>
    >
    > 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
     
  12. RichardOnRails

    RichardOnRails Flightless Bird

    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
     

Share This Page