Showing posts with label dos. Show all posts
Showing posts with label dos. Show all posts

Wednesday, July 17, 2019

LABELS not working in .bat file. Error: The system cannot find the batch label specified

I've often run across the issue where
- I write a .bat file with a label.
- The label is quite valid
- The system throws the error: The system cannot find the batch label specified

I've found this to be an issue of line terminators.
I typically use Notepad++ for editing .bat files. It tends to use Unix line terminators. (Just LF, or \n)
I need to change these to be \r\n (carriage return & new line)

This also seems to impact statement blocks for IF statements.
Example:
IF "%1"=="SomeValue"(
  echo %1
  echo I just echoed %1
  set myvalue=%1
)

I have not carefully tested, but I get the same sort of weird errors for perfectly valid statements. I'm guessing they're related.

Best of luck!

Tuesday, March 19, 2013

Issues with AIX newline characters on KSH files developed on Windows


To fix issues with the ^M from developing a .KSH file on windows and then uploaded to AIX:
1 - edit the file in vi (extremly useful vi cheatsheet found here: Vi Cheatsheet from LagMonster)
2 - do a substitution using the following keystrokes: :%s/[ctrlkey+v and ctrl-key+M]//g
This will appear as ...  :%s/^M//g … when you type it.
3 - save with :x

However, note that the command does not look like he says it does.  He reports the ctrl-v as printing this: :%s/^V^M//g.  For me, it did this: :%s/^M//g.

Get Restart log using PowerShell

I'm often curious about a restart on a Windows server system. An easy way to get a list of the restart and what initiated it is to use t...