Tuesday, May 26, 2009

Batch: '-' issues

Today, I encountered something unusual at work.

~ I had an application (say app.exe) that accepted parameters; for e.g., if "App.exe -i" command is executed, the application would get installed on the system.
~ Also, I had a BATCH script that would call App.exe with options for further processing.
But somehow the script didn't run effectively. I had to use the command, "App.exe -i" in the script and when I ran the script, to my surprise, I could see the command being executed as "App.exe ϋi" instead of "App.exe -i". That is, instaed of "-" it ran as "ϋ" on the command prompt.
Where did this "ϋ" come from??

After struggling for an hour or so I could gauge that the "ϋ" sign was because of the space between App.exe and -i in the command.

The simple solution was to use a ESCAPE sequence before the space. Hence I scripted the command as "App.exe^ -i". where ^ is the escape sequence in DOS and then space was no more an issue.

Interesting isn't it!! :-)