1.

Solve : writing a dos command, would like advice please?

Answer»

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" )


There is no "or", you'll need to run three different commands.

The != is expressed as ' if not __ == __ '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

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"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"
Guys that is just too cool. Thanks so much! Quote from: foxidrive on March 30, 2015, 05:03:54 PM

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


Discussion

No Comment Found