command-line-interface

How to escape strings for terminal in Ruby?

*爱你&永不变心* 提交于 2019-12-18 12:09:33
问题 I am attempting to start mplayer. My filename contains spaces and these should be escaped. This is the code I am using: @player_pid = fork do exec "/usr/bin/mplayer #{song.file}" end where #{song.file} contains a path like "/home/example/music/01 - a song.mp3" . How can I escape this variable properly (and possible other weird characters that the title may contain) so the terminal will accept my command? 回答1: Shellwords should work for you :) exec "/usr/bin/mplayer %s" % Shellwords.escape

Call a PHP function from the command line

给你一囗甜甜゛ 提交于 2019-12-18 11:41:10
问题 I have a file called address.php with a few functions in it. I want to call a specific function in that file from the command line. How? The name of the function is called exportAddress and that function expects a single parameter. 回答1: By using the -r parameter you can run a script in-line. php -r "require 'address.php'; exportAddress(12345);" There are no other options. A function in PHP can only be called by a PHP script. 回答2: php -r 'include "/var/www/test/address.php";exportAddress(1);'

What is the REST (or CLI) API for logging in to Amazon Cognito user pools

╄→尐↘猪︶ㄣ 提交于 2019-12-18 11:05:51
问题 How do i make logins happen via Amazon Cognito REST APIs (for user pools) on platforms for which there is no official SDK? - Note that i am asking for user pools - not identity pools. Synopsis Amazon cognito provides 3 kinds of logins: federated logins (creates identity pools ) - using social connects like FB, Twitter, G+ etc AWS managed logins (creates user pools ) - using Amazon's own managed signup, signin, forgot password, reset password services developer provided logins (my custom

envsubst: command not found on Mac OS X 10.8

泪湿孤枕 提交于 2019-12-18 10:22:49
问题 When I try to run a script that contains the envsubst command, I get this error. Looking online, this seems to be a standard bash command, so I am not sure what to install in order to get it to work. 回答1: Edit: @cobberboy 's anwer is more correct. upvote him. brew install gettext brew link --force gettext Following is my old answer: envsubst is included in gettext package. Therefore you may compile it by your own, using standard build tools such as make or using homebrew . However, it seems

Cordova Error: Failed to fetch platform cordova-browser@~5.0.0

旧巷老猫 提交于 2019-12-18 09:15:09
问题 when i build cordova project it working fine. output also shown.But, after few minutes later it shows this error Error: Failed to fetch platform cordova-browser@~5.0.0 PS C:\Users\Rajadurai\Desktop\app> phonegap serve [phonegap] starting app server... [phonegap] listening on 127.0.0.1:3000 [phonegap] [phonegap] ctrl-c to stop the server [phonegap] [phonegap] 200 /socket.io/?EIO=3&transport=polling&t=M6UXY64 [phonegap] 200 /socket.io/?EIO=3&transport=polling&t=M6UXY79&sid=rXL4l2-OqPKmfZW6AAAA

Running Codeigniter via CLI outputs website root instead of expected result

匆匆过客 提交于 2019-12-18 07:36:54
问题 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? 回答1: try this: php index.php/controller/function

Get console user input as typed, char by char

谁说我不能喝 提交于 2019-12-18 07:36:15
问题 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

How to distinguish between CLI & CGI modes in Perl

给你一囗甜甜゛ 提交于 2019-12-18 05:15:26
问题 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? 回答1: 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"; } 回答2: At a guess,

How can I force PHP Version for Command Line?

99封情书 提交于 2019-12-18 04:42:20
问题 I am hosted with 1and1.com, and I have setup my files to be parsed with php5 using .htaccess . But that only works in apache, and not in command line, which defaults to the server default php4. So currently I can not setup cron jobs to run my code as php5. Any ideas? 回答1: If both are installed, all you need to do is run the script using the relevant PHP binary. So for example: // Runs using the PHP binary located at /usr/bin/php * * * * * root /usr/bin/php -n "/path/to/script.php" or // Runs

How can I force PHP Version for Command Line?

别说谁变了你拦得住时间么 提交于 2019-12-18 04:42:16
问题 I am hosted with 1and1.com, and I have setup my files to be parsed with php5 using .htaccess . But that only works in apache, and not in command line, which defaults to the server default php4. So currently I can not setup cron jobs to run my code as php5. Any ideas? 回答1: If both are installed, all you need to do is run the script using the relevant PHP binary. So for example: // Runs using the PHP binary located at /usr/bin/php * * * * * root /usr/bin/php -n "/path/to/script.php" or // Runs