I think the best option would be to go with the Services module. About the module from the project page:
A standardized solution of integrating external applications with Drupal. Service callbacks may be used with multiple interfaces like REST, XMLRPC, JSON, JSON-RPC, SOAP, AMF, etc. This allows a Drupal site to provide web services via multiple interfaces while using the same callback code.
You can build the other application (like android app, Java app, and many more...) in any programming languages you like and make the application interact with Drupal using Services. There is an extensive documentation available which would help you through.
Take time to read through the project page (as it contains more resources to explore) and the documentation as it might take time to get accustomed with the module (as it happened with me).
For command line access to Drupal there is a "Command line shell and scripting interface" - Drush (Drupal Shell). List of the Drush commands could be found at this site. It is very powerful utility for Drupal developers (on Windows, Ubuntu Linux, Mac, etc.); but I'm not sure if one is able to create/modify/read content (nodes) with Drush though, I think one cannot do that (please correct me if I'm wrong).