Can Mingw32/Msys run dos/cmd.exe executables without screwing up the arguments?

7

3

I'm trying to run growlnotify.exe from a Windows bash prompt. Recompiling it for mingw32 isn't a good option for me.

growlnotify works if I use it from the cmd prompt, but it fails (mostly) from the bash prompt. It only seems to be able to take a single argument, one without a switch (which is the notification message). If there is more than one argument, it fails silently. If there is a single switch and no other arguments, that switch is sent as the message.

I've managed to dig up some hints on Google that it has something to do with the way Windows doesn't provide a real tty, but no fixes. Is there any clever way to force this to work? Some way of escaping the arguments correctly such that it behaves as expected?

New information:

If I run it it with tripled slashes, the arguments are ignored. Whereas if I run it with what is the correct format in DOS, it fails silently.

Failure (also failes if I use //):

growlnotify /a:'Application Name' /n:'Notification Type' 'message goes here'

But this:

growlnotify ///a:'Application Name' ///n:'Notification Type' 'message goes here'

That one will send a notices with the 'message goes here', but as if I hadn't bothered to include the first two arguments. Single or double slashes though, it never sends a notice (as if I included no arguments at all).

Quadruple and quintuple slashes behave the same as triple slashes.

Explanation of the various switches.

John O

Posted 2013-02-27T22:29:27.180

Reputation: 615

@Maximus Another way to see the final command-line substitutions is to pass the arguments to a .bat script instead of cmd.exe. They will be printed by default, unless @ or echo off is used to suppress line printing.

The script could use cmd %* to pass arguments to cmd.exe.

– jpaugh – 2018-05-08T15:42:28.683

Try growlnotify.exe //a:Lync testmessage – Maximus – 2013-02-28T00:11:58.830

@Maximus that also fails. I've tried escaping it with /a: as well, and every combination of doubled and tripled slashes that there are. – John O – 2013-03-01T14:56:17.800

Hum, you may check, what command line is passed to exe. Look in TaskManager or ProcessExplorer. What changes in cmdline was made by bash prompt? – Maximus – 2013-03-01T21:07:21.390

@Maximus The exe exits nearly immediately, if it's showing up in Task Manager, I can't tell. – John O – 2013-03-01T21:11:33.063

Answers

10

Ok, the proper answer follows.

To escape the arguments such that dos executables can be used, you double the slashes, such as:

growlnotify //a:Application //t:Title "message here"

The reason it would fail for me was because somehow I wasn't using the same application name as I had when I started the day before (and as a different application it was unregistered, and Growl For Windows ignores unregistered notifications).

There are a few other tricks worth mentioning. In CMD, you can issue the statement like this:

growlnotify //a:App //t:"With Spaces" "message here"

The "With Spaces" bombs. I think msys/bash may be expanding the quotes, and then passing it in, such that the executable sees two arguments, //t:With and Spaces". The correct way to do that seems to be:

growlnotify //a:App //t:With\ Spaces "message here"

Also, if you pass in any filepaths, you'll still want to use DOS-style, which means slashes (since ultimately it's the DOS-like executable that will consume that). But those will be interpreted as escapes, which means they have to be doubled as well.

growlnotify //a:App //ai:C:\\path\\to\\icon.png "message here"

Hope this helps someone in the future.

John O

Posted 2013-02-27T22:29:27.180

Reputation: 615

4

Have you tried running "cmd.exe /c growlnotify.exe ..." from MinGW?

Mikhail Kupchik

Posted 2013-02-27T22:29:27.180

Reputation: 2 381

Thank you so much @c24w. I was stuck in such problem all day. – gustavohenke – 2014-11-28T18:10:31.680

I have not, I will now. – John O – 2013-02-27T22:37:11.433

This doesn't seem to work, I run it as cmd.exe /C "growlnotify.exe /a:Lync testmessage" but this just drops me to a cmd.exe prompt without doing anything. – John O – 2013-02-27T22:40:17.793

9

Got this working with cmd //c [command]. In MSYS a command line argument of "/c" is interpreted as the C: drive, so to pass any argument beginning with a forward slash you need to use two forward slashes. Source.

– c24w – 2013-06-14T10:27:37.043