command-line-interface

Running Codeigniter via CLI outputs website root instead of expected result

对着背影说爱祢 提交于 2019-11-29 13:17:51
I'm following this tutorial on running Codeigniter via the CLI. I've done everything they've done (copied and pasted) now when I run this command, it doesn't do what is expected except it outputs the website index contents. $ cd /Users/MyUsername/Sites/code $ php index.php tools message The output I get is the index page HTML source, e.g. http://localhost/code . The expected result should be Hello World! How can I achieve this to make it work? Vlad Balmos try this: php index.php/controller/function/param1/param2/param3 etc or php index.php controller function param1 param2 param3 etc also,

Python Click - Supply arguments and options from a configuration file

孤人 提交于 2019-11-29 13:16:46
问题 Given the following program: #!/usr/bin/env python import click @click.command() @click.argument("arg") @click.option("--opt") @click.option("--config_file", type=click.Path()) def main(arg, opt, config_file): print("arg: {}".format(arg)) print("opt: {}".format(opt)) print("config_file: {}".format(config_file)) return if __name__ == "__main__": main() I can run it with the arguments and options provided through command line. $ ./click_test.py my_arg --config_file my_config_file arg: my_arg

Get console user input as typed, char by char

穿精又带淫゛_ 提交于 2019-11-29 13:15:42
I have a console application in Elixir. I need to interpret user’s input on by keypress basis. For instance, I need to treat “q” as a command to end the session, without user to explicitly press ⏎ a.k.a. “carriage return.” IO.getn/2 surprisingly waits for the ⏎ to be pressed, buffering an input (I am nearly sure, that this buffering is done by console itself, but man stty does not provide any help/flag to turn buffering off.) Mix.Utils use the infinite loop to hide user input (basically sending backspace control sequence to console every 1ms,) IEx code wraps calls to standard erlang’s io ,

$_SERVER document root in CLI

你。 提交于 2019-11-29 09:51:14
In CLI $_SERVER['DOCUMENT_ROOT'] is not working. How can I fix this? Is there any other option available. I cannot use relative paths, because files are in various directories. $_SERVER contains headers which won't be available in the CLI. The web server defines the document root. In the CLI, you aren't using a web server, so there is no document root. You can try to rely on environmental variables, assuming they are set by your shell. For instance, PWD represents the current directory and HOME represents the user's home directory. $pwd = getenv('PWD'); $home = getenv('HOME'); You can also use

How to differentiate between http and cli requests?

我的梦境 提交于 2019-11-29 09:50:34
The title is quiet straightforward. I have to know on server side if the script called through HTTP request or by command line. I could examine the $_SERVER['argv'] or $_SERVER['argc'] . What is the pragmatic way to do that? http://us3.php.net/manual/en/function.php-sapi-name.php <?php echo PHP_SAPI; echo php_sapi_name(); ?> Look at the keys in $_SERVER . If it is a cli request, you shouldn't see any that start with "HTTP". Here is some simple test code: <?php foreach( $_SERVER as $k=>$v ){ echo "$k: $v\n"; } ?> And here is the output: aj@mmdev0:~/so$ php cli.php |grep HTTP aj@mmdev0:~/so$

Python DistributionNotFound Error after installing EB CLI 3.0

走远了吗. 提交于 2019-11-29 09:49:31
Have tried many things, but keep getting this error after multiple attempts to update python, pip, etc. I am on OS X running 10.9.5. CMD% eb Traceback (most recent call last): File "/usr/local/bin/eb", line 5, in <module> from pkg_resources import load_entry_point File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module> File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg

How to distinguish between CLI & CGI modes in Perl

隐身守侯 提交于 2019-11-29 08:13:25
I am supposed to write a Perl script which can be run both on the command line and as a CGI script. I haven't been able to determine how I should distinguish between the two modes. So could you please let me know how to implement the logic? You can check for the presence of any number of CGI environment variables , e.g.: if ($ENV{GATEWAY_INTERFACE}) { print "Content-type: text/plain\n\nLooks like I'm a CGI\n"; } else { print "I'm just a plain command line program\n"; } At a guess, $ENV{'GATEWAY_INTERFACE'} will be NULL when run from the command line, and contain something (e.g. 1.1) when run

Generating python CLI man page

倖福魔咒の 提交于 2019-11-29 08:04:45
问题 I am developing a python CLI tool (using optparse in python2.6, but hope to switch soon to python2.7) and I am about to write the man page. I have some experience on generating dynamic man pages by: creating a dedicated method that composes a string in pod format and writes it to a file executing the pod2man command to generate data in groff format to be passed to the man command I would also like to generate wiki pages with the same content as the man page (with pod I can generate html

How do I see high-precision query times in mysql command line?

邮差的信 提交于 2019-11-29 07:50:52
问题 I'm working through some optimization work, and I've noticed that in some mysql dumps people post in articles and questions (which I cannot find again now that I'm actually looking), there are high-precision execution times (0.05985215 sec instead of 0.06 sec). How can I see these more precise times for my queries on the command line? EDIT Example of this is: +----------+ | COUNT(*) | +----------+ | 11596 | +----------+ 1 row in set (0.05894344 sec) Using profiling gets me part of the way

How to debug python CLI that takes stdin?

非 Y 不嫁゛ 提交于 2019-11-29 06:49:34
问题 I'm trying to debug a Python CLI I wrote that can take its arguments from stdin. A simple test case would have the output of echo "test" | python mytool.py be equivalent to the output of python mytool.py test I'd like to debug some issues with this tool, so I tried to run this: echo "test" | pdb mytool.py But I get this output, then pdb exits: > /path/to/mytool.py(5)<module>() -> ''' (Pdb) *** NameError: name 'test' is not defined (Pdb) The same thing occurs when I add -m python to the