Integrating command line prompt

Hello everyone,

I am using CommandBox to run Coldfusion scripts from the command line. What I am wondering is how to get a user input that could be inputted inside the coldfusion script. Either through a prompt or passing it as a script argument.

The way I am doing it now is prompting from bash, inserting it into a file and have the CF script get the info from the file, the trouble is some of these info are passwords, and I don’t want them stored in files as it could be a security issue.

Can you show us how you’re calling the .cfm? Also, what operating system are you using?

Parameters are supposed to work, but they’ve been a bit buggy and honestly not many people have expressed interest in the feature so it’s just not gotten much love.

Note, this is all a little uneccessarily complicated since there’s at least 4 ways to “run CFML from the command line” right now.

  1. $> box foo.cfm
  2. $> box execute foo.cfm
  3. CommandBox> execute foo.cfm (In the interactive shell)
  4. $> ./foo.cfm (Using #!/usr/bin/env box on a Unix server)
    Each of those have a slightly different way they behave. I think I’ve also seen some bugs related to how Windows pathing is handled differently than Unix. Params DO work in option 3 (from within the interactive shell) but don’t seem to be working in option 1 or 2 right off. Unfortunately, options 1, 2, and 4 are handled in the Java CLI loader classes which I don’t have any immediate control over so I’ve never really been able to dig in and straighten it out.

Can you put in a ticket for this and we can look at it for our 2.0 release? Help is always welcome.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I’m using ‘box script.cfm’ to run my script, I am on a MAC using OS X Yosemite.

Here’s roughly where that gets handled:
https://github.com/denuno/railo-cli/blob/master/src/java/cliloader/LoaderCLIMain.java#L299

It looks like the ‘execute’ is being taken out which bypasses the CommandBox framework and just execute the .cfm directly on the Railo CLI which is too bad. Let me know when you have a ticket put in.

Follow these instructions, but just select the “commandbox” project.

http://blog.coldbox.org/blog/how-to-create-a-jira-account-and-enter-coldbox-tickets

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

I think I’m gonna go with the new command option creation, to have it take in a parameter straight from the box customCommand param1

I don’t think it really needs a ticket as it shouldn’t be needed normally as I’m using CommandBox for something it’s not really supposed to be used for

Regards,

Antoine

I think I’m gonna go with the new command option creation, to have it take in a parameter straight from the box customCommand param1

That’s a good choice. You have a lot more useful stuff available to you if you create a custom command. Read up here:
http://ortus.gitbooks.io/commandbox-documentation/content/developing_commands/developing_commands.html

I don’t think it really needs a ticket as it shouldn’t be needed normally as I’m using CommandBox for something it’s not really supposed to be used for

No, parameter handling def needs a ticket. It’s rather broken right now. I would also say there’s no real right/wrong way to be using CommandBox. Heck, I’m using the REPL right now to “bit bang” shift registers on a Raspberry Pi so I can control an LED matrix. You can read all about it on my new blog hosted via CommandBox on a Pi as well. I’d say it’s looking pretty limitless right now :slight_smile:
http://pi.bradwood.com/blog/neo-the-led-matrix-has-you

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Created here https://ortussolutions.atlassian.net/browse/COLDBOX-459

Thanks. You created it under the ColdBox project on accident, but I moved it to CommandBox for you :slight_smile:

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com