command-line-interface

Run a PHP script every second using CLI

喜你入骨 提交于 2019-11-26 10:54:09
问题 I have a dedicated server running Cent OS with a Parallel PLESK panel. I need to run a PHP script every second to update my database. These is no alternative way time-wise, it needs to be updated every second. I can find my script using the URL http://www.somesite.com/phpfile.php?key=123 . Can the file be executed locally every second? Like phpfile.php ? Update: It has been a few months since I added this question. I ended up using the following code: #!/user/bin/php <?php $start = microtime

Using django for CLI tool

夙愿已清 提交于 2019-11-26 10:37:28
Is there any sense in using Django framework for developing Command Line Interface tool? In my case there won't be any graphical interface. What benefits can I get using it? Or maybe you know any other useful frameworks for CLI? I'd like to put an accent on making HTTP requests with REST API. UPDATE: Thanks guys! I would like rather to use REST API than create it in my tool. e4c5 While django is primarily for web apps it has a powerful and easy to use ORM that can be used for CLI apps as well. To use django script as a standalone script without a webserver, all you need to do is to add the

Is there a way to make a console application run using only a single file in .NET Core?

↘锁芯ラ 提交于 2019-11-26 09:58:29
问题 In .NET framework, you can make a single .EXE file that will run from the command line without having any extra config files (and if using ILMerge, you can put all .DLL references into the 1 .EXE assembly). I am taking a stab at using .NET Core to accomplish the same thing, but so far without success. Even the simplest Hello World application with no dependencies requires there to be a file named <MyApp>.runtimeconfig.json in order to run using dotnet.exe . dotnet F:\\temp\\MyApp.dll The

PHP CLI: How to read a single character of input from the TTY (without waiting for the enter key)?

感情迁移 提交于 2019-11-26 09:30:50
问题 I want to read a single character at-a-time from the command line in PHP, however it seems as though there is some kind of input buffering from somewhere preventing this. Consider this code: #!/usr/bin/php <?php echo \"input# \"; while ($c = fread(STDIN, 1)) { echo \"Read from STDIN: \" . $c . \"\\ninput# \"; } ?> Typing in \"foo\" as the input (and pressing enter), the output I am getting is: input# foo Read from STDIN: f input# Read from STDIN: o input# Read from STDIN: o input# Read from

Laravel 5 – Clear Cache in Shared Hosting Server

泄露秘密 提交于 2019-11-26 07:56:57
问题 The question is pretty clear. php artisan cache:clear Is there any workaround to clear the cache like above we using in CLI. I am using a popular shared hosting service, but as per my plan, I don\'t have control panel access. ** I want to clear the views cache.** I saw a question almost the same as this, but it doesn\'t help me. 回答1: You can call an Artisan command outside the CLI. Route::get('/clear-cache', function() { $exitCode = Artisan::call('cache:clear'); // return what you want });

Execute and get the output of a shell command in node.js

耗尽温柔 提交于 2019-11-26 06:59:39
问题 In a node.js, I\'d like to find a way to obtain the output of a Unix terminal command. Is there any way to do this? function getCommandOutput(commandString){ // now how can I implement this function? // getCommandOutput(\"ls\") should print the terminal output of the shell command \"ls\" } 回答1: Thats the way I do it in a project I am working now. var exec = require('child_process').exec; function execute(command, callback){ exec(command, function(error, stdout, stderr){ callback(stdout); });

Is there an easy way to pass a “raw” string to grep?

蓝咒 提交于 2019-11-26 04:45:14
问题 grep can\'t be fed \"raw\" strings when used from the command-line, since some characters need to be escaped to not be treated as literals. For example: $ grep \'(hello|bye)\' # WON\'T MATCH \'hello\' $ grep \'\\(hello\\|bye\\)\' # GOOD, BUT QUICKLY BECOMES UNREADABLE I was using printf to auto-escape strings: $ printf \'%q\' \'(some|group)\\n\' \\(some\\|group\\)\\\\n This produces a bash-escaped version of the string, and using backticks, this can easily be passed to a grep call: $ grep

How to access PHP with the Command Line on Windows?

微笑、不失礼 提交于 2019-11-26 04:43:48
问题 I am trying to learn how to access PHP scripts from the command line (CLI) Below is an image from my attempt, please help. I am running Windows 7 回答1: You need to add your PHP installation directory to the %PATH% environment variable, or work from the PHP installation directory. To add it to path (The best approach - Edited for Windows 7 ): Right-click on a My Computer icon Click Properties Click Advanced system settings from the left nav Click Advanced tab Click Environment Variables button

Remove first N lines of a file in place in unix command line

坚强是说给别人听的谎言 提交于 2019-11-26 04:26:42
问题 I\'m trying to remove the first 37 lines from a very, very large file. I started trying sed and awk, but they seem to require copying the data to a new file. I\'m looking for a \"remove lines in place\" method, that unlike sed -i is not making copies of any kind, but rather is just removing lines from the existing file. Here\'s what I\'ve done... awk \'NR > 37\' file.xml > \'f2.xml\' sed -i \'1,37d\' file.xml Both of these seem to do a full copy. Is there any other simple CLI that can do this

Can&#39;t get argparse to read quoted string with dashes in it?

南楼画角 提交于 2019-11-26 03:58:03
问题 Is there a way to make argparse recognize anything between two quotes as a single argument? It seems to keep seeing the dashes and assuming that it\'s the start of a new option I have something like: mainparser = argparse.ArgumentParser() subparsers = mainparser.add_subparsers(dest=\'subcommand\') parser = subparsers.add_parser(\'queue\') parser.add_argument(\'-env\', \'--extraEnvVars\', type=str, help=\'String of extra arguments to be passed to model.\') ...other arguments added to parser...