CMD and SG 2010 – Part 5.

This is today… Today I will have a chance to speak to THEM. Good day to finalize my series. Not the best day to do shopping, since my bank card expired. 😉 So no real breakfast today.

Last two events were not very hard, but I had two problems to move them to CMD.

Event 9 required array manipulation but… there is no array in CMD! So what should I do? Well, I tried to ‘pretend’ I was playing with arrays. So it’s not a script I could easily defend. Probably one star only. 😉

CMD, using GeSHi 1.0.8.8 – Beginner Event 9
  1. @echo off
  2. SET Arr1=a b c d
  3. SET Arr2=d e f g
  4.  
  5. echo Array 1 = %Arr1%
  6. echo Array 2 = %Arr2%
  7. set Arr3=
  8.  
  9. call :Conc %Arr1%
  10. call :Conc %Arr2%
  11.  
  12. echo Final Array = %Arr3%
  13. goto :EOF
  14.  
  15.   :Conc
  16.   if [%1]==[] goto :EOF
  17.   echo %Arr3% | findstr /r "%1," > nul || (SET Arr3=%Arr3%%1, & echo %1)
  18.   goto :Conc
  19.  

Second was even harder: how to debug .vbs or .ps1 when I use cmd only? I decided to take other route: OK boss, I’m not fluent in either, I will get your message box in cmd, and leave those broken scripts alone. 😉 There is no ‘silentlycontinue’ in cmd (unless you redirect 2> nul) so if I hit error – I will know it. So that’s what I came up with:

CMD, using GeSHi 1.0.8.8 – Beginner Event 10
  1. @echo off
  2. for /f %%M in (‘wmic ComputerSystem Get UserName ^| findstr /r ".*\.*"’) do @SET msg=%%M
  3. msg %USERNAME% %msg%

See? Message box as you expected. Title may be a little confusing, but who would read title in a window like that? 😉 So again: not exactly what Scripting Guys asked for, but I had to limit my self to command line tools only.

And now I have few long hours ahead. I plan to get to bed early and today (tomorrow my time) wake up in the middle of the night, drive to work (so that I would not wake up my family while recording podcast). So two big issues ahead of me: how to concentrate on what I’m doing when at work, and how to fall asleep when at home. 😉 I usually go to bed around 1-2, so it may be a real problem. So plan B is stay at home, and call podcast team from bathroom 😉 Will see how it all works out for me.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s