Second command prompt not closing after installation completed

Discussion in 'Windows Server Forums' started by Ravi Kumar, Jun 29, 2016.

Tags:
  1. Ravi Kumar

    Ravi Kumar New Member

    Joined:
    Jun 29, 2016
    Messages:
    4
    Likes Received:
    0
    Am creating a batch script to install ruby gems along with some other automation. But when "gem install <gemname>" command triggered its opened new command prompt to install and its not closing it as soon as gem installation completed.

    I tried below things as well which didn't help me,

    START /WAIT /b gem install --no-rdoc --no-ri json
    START /WAIT gem install --no-rdoc --no-ri json /b

    Can someone help me out to get the additional command prompt closed as soon as installation completed
     
  2. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    Can I ask why you're even using the START command to begin with?
     
  3. Neemobeer

    Neemobeer Windows Forum Team
    Staff Member

    Joined:
    Jul 4, 2015
    Messages:
    2,400
    Likes Received:
    361
    Yeah you shouldn't need Start at all. If you want to explicitly close the cmd just add exit at the end of the batch file
     
  4. Ravi Kumar

    Ravi Kumar New Member

    Joined:
    Jun 29, 2016
    Messages:
    4
    Likes Received:
    0
    Okay. I tried without using START and below the current script.

    @echo OFF
    echo Installing Gems
    gem install --local --quiet --no-rdoc --no-ri ffi-1.9.10-x86-mingw32.gem ffi-1.9.10-x64-mingw32.gem
    echo Completed Gems installation



    Once the gem installation completed am not getting the message "Completed Gems installation". Below is the output of this script,

    c:\temp>gem_install.bat
    Installing Gems
    Successfully installed ffi-1.9.10-x86-mingw32
    Successfully installed ffi-1.9.10-x64-mingw32
    2 gems installed

    c:\temp>
     
    #4 Ravi Kumar, Jun 30, 2016
    Last edited: Jun 30, 2016
  5. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    I mean... your "2 gems installed" message is just as good as "Completed Gems installation"

    You can also redirect text to a file in batch scripting then use the type command to display it.

    The only thing I can think of as far as your second echo not working correctly is that the gem command is altering the command prompt space somehow therefore breaking it. You could try an "ECHO ." after it which might mitigate the problem..

    Or you can try something like this...
    @echo OFF
    @echo Installing Gems >> install.log
    @gem install --local --quiet --no-rdoc --no-ri ffi-1.9.10-x86-mingw32.gem ffi-1.9.10-x64-mingw32.gem >> install.log
    @echo Completed Gems installation >> install.log
    @echo Installation results:
    @type install.log
     
  6. Ravi Kumar

    Ravi Kumar New Member

    Joined:
    Jun 29, 2016
    Messages:
    4
    Likes Received:
    0
    Hmm I also suspect gem command is altering the command prompt behavior. I tried the method which you suggested and getting the same result only.

    Below is the output I got in install.log file.

    Installing Gems
    Successfully installed ffi-1.9.10-x86-mingw32
    Successfully installed ffi-1.9.10-x64-mingw32
    2 gems installed
     
  7. Josephur

    Josephur Windows Forum Admin
    Staff Member Premium Supporter

    Joined:
    Aug 3, 2010
    Messages:
    1,019
    Likes Received:
    125
    You should look into the cmd /k option.

    cmd /k gem install --local --quiet --no-rdoc --no-ri ffi-1.9.10-x86-mingw32.gem ffi-1.9.10-x64-mingw32.gem >> install.log
     
    Ravi Kumar likes this.
  8. Ravi Kumar

    Ravi Kumar New Member

    Joined:
    Jun 29, 2016
    Messages:
    4
    Likes Received:
    0
    Cool.. It worked. Thanks a lot!
     

Share This Page

Loading...