Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: writing a dos command, would like advice please  (Read 3189 times)

0 Members and 1 Guest are viewing this topic.

Redd4

    Topic Starter


    Rookie

    • Experience: Familiar
    • OS: Windows XP
    writing a dos command, would like advice please
    « on: March 30, 2015, 09:27:06 AM »
    Hello all,

     Im creating a Jenkins job, and wondering will the following work. I am a total novice at this stuff so please forgive me if the below sounds silly.

    Basically I want to restart all nodes - unless they are called dugan, dione or example. I know i cant use != in dos but im having a job sercing for what I can use..

    if %computername% != DUGAN,DIONE,EXAMPLE ( shutdown -r -f -t 10 -c "This computer is about to restart" )



    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: writing a dos command, would like advice please
    « Reply #1 on: March 30, 2015, 12:45:02 PM »
    There is no "or", you'll need to run three different commands.

    The != is expressed as ' if not __ == __ '
    Quote from: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: writing a dos command, would like advice please
    « Reply #2 on: March 30, 2015, 12:50:23 PM »
    I don't know if the jenkins command line Build Step allows multiple lines. I know it just get's written to a temporary file and run as a batch, so it probably does. (personally I usually just have it run a batch script that is part of the SVN repository so it can be updates along with the software it builds, but perhaps you are using jenkins for another purpose).

    Code: [Select]
    if %computername%==DUGAN goto norestart
    if %computername%==DIONE goto norestart
    if %computername%==EXAMPLE goto norestart
    shutdown -r -f -t 10 -c "this computer is about to restart"
    :norestart

    I was trying to dereference Null Pointers before it was cool.

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: writing a dos command, would like advice please
    « Reply #3 on: March 30, 2015, 12:54:13 PM »
    Code: [Select]
    @echo off
    set computerlist=DUGAN,DIONE,EXAMPLE
    call set templist=%%computerlist:%computername%=%%
    IF "%computerlist%"=="%templist%" shutdown -r -f -t 10 -c "This computer is about to restart"

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    Re: writing a dos command, would like advice please
    « Reply #4 on: March 30, 2015, 05:03:54 PM »
    How many cats do we have to skin?  Here's another way:

    Code: [Select]
    @echo off
    for %%a in (DUGAN DIONE EXAMPLE) do if /i "%computername%"=="%%a" goto :EOF
    shutdown -r -f -t 10 -c "this computer is about to restart"

    Redd4

      Topic Starter


      Rookie

      • Experience: Familiar
      • OS: Windows XP
      Re: writing a dos command, would like advice please
      « Reply #5 on: March 30, 2015, 05:24:28 PM »
      Guys that is just too cool. Thanks so much!

      Squashman



        Specialist
      • Thanked: 134
      • Experience: Experienced
      • OS: Other
      Re: writing a dos command, would like advice please
      « Reply #6 on: March 31, 2015, 07:23:48 AM »
      How many cats do we have to skin?  Here's another way:
      I saw a poor dead kitty on the side of the road on my bike ride yesterday.  :'(

      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: writing a dos command, would like advice please
      « Reply #7 on: March 31, 2015, 09:33:57 PM »
      Aww.. poor kitty!

      Code: [Select]

                          //Z/Z//                 
                   |\    //Z/Z//   _,,,--,,_       
                   /x`. //Z/Z//-'`'   ._  \-;;,_   
                  |x4- //Z/Z//  ) )_   .;.(  `'-' 
                 '---'//Z/Z//'(_/._)-'(_\_)       
                     //Z/Z//                       
                    //Z/Z//
       


      Here's my kitty when he was younger.  ;)

      Code: [Select]
              (`.
               ) )
              ( (
               \ \
                \ \
              .-'  `-.
             /        `.
            (      )    `-._ ,    _
             )   ,'         (.\--'(
             \  (         ) /      \
              \  \_(     / (    <6 (6
               \_)))\   (   `._  .:Y)__
                '''  \   `-._.'`---^_)))
                      `-._ )))       ```
                           ```


      In a futile attempt to remain on-topic...

      Code: [Select]
      dir /b mouse.drv >"cat mouth.txt"