Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I've quickly searched through this site and Google, but I did not find the answer. I started to use new Force.com CLI on Windows, but I faced with trouble that I can't run apex code from command line (I tried Cygwin and cmd shells).

The trouble is that the CLI just do nothing. Help says that for running a code I need to type my code and just pres [Control + D], but it seems not working for me.

I tried different keys combinations based on the Wikipedia article about mapping a keyboard shortcuts on different OS as well as random pressing the most known keys combinations. Other commands work normally.

Thanks.

share|improve this question
    
See also Equivalent to ^D (in bash) for cmd.exe? –  Daniel Ballinger Dec 17 '13 at 22:47
    
@DanielBallinger Thanks for your link, yes, I did it, but it does not work. –  Pavel Dec 18 '13 at 4:26
add comment

1 Answer 1

up vote 16 down vote accepted

I observe the same thing. It just hangs and I have to hit CTRL-C to leave get out of it and nothing happens. Also, CTRL-Z didn't work.

You can create a file and you can actually just pass the name of the file as a parameter to the force apex command as that is one of the supported parameters.

If you run force help apex you get the the usage:

force apex usage

For example, create a file called anonApex.txt in the directory you are in and put System.debug('hello world'); in it.

Then, from the command line:

C:\path\to\your\dir>force apex anonApex.txt

You get something like:

force apex cmd

Perhaps it has something to do with detecting, from the command line, an end of transmission or end of file character difference between *nix and Windows. I wouldn't be surprised if CTRL-D worked on *nix based systems. Usually it is CTRL-Z on Windows.

I believe my guess at the this to be confirmed. I found the following issue logged against the Go Programming language:

Issue 6303: syscall: reading os.Stdin does not treat ^Z as EOF on Windows which looks a lot like what we are observing.

After reading over that issue and related discussions, I think that the handling of CTRL-Z for Windows console apps is not a high priority for the Go Programming language, so it looks like the only way to use the force apex command from Windows is with a file input. CTRL-Z will not work unless the underlying Go Programming language changes.

share|improve this answer
1  
Thanks a lot Peter, you're my personal hero! I was going to use this feature in build scripts in order to reduce the efforts of my team and I was really upset when found this issue, but your answer brought me back to life. Thank you again. –  Pavel Dec 18 '13 at 4:35
1  
@Pavel - No problem. Glad I could help! :) –  Peter Knolle Dec 18 '13 at 20:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.