command-line-interface

How create shell commands from C functions

痴心易碎 提交于 2019-12-05 18:13:35
Wondering how to take a set of C functions and turn them into shell/bash commands. So say I have a simple set of C functions int fn1() { // some C code for function 1. } int fn2() { // some C code for function 2. } int fn3() { // some C code for function 3. } I would like to then somehow create CLI commands so I can use them from the terminal. $ fn1 <param> <param> ... $ fn2 ... $ fn3 ... Not sure what the process is of doing this. If I need to somehow rewrite all the function interfaces in shell script, and then call of to a C function in some way, sort of like this (bash script): fn1() {

Give permission for bjyauthorize to run mvc application of ZF2 from CLI

白昼怎懂夜的黑 提交于 2019-12-05 17:36:40
I have a completely running mvc application on ZF2. I want to run some actions from command line. I have properly set up my console routes and other environments. When I run my app from CLI, I got Permission denied exception like this: 'You are not authorized to access GeneratePdf\Controller\GeneratePdf\GeneratePdf:generate-all' in /var/www/zf2-reporting/module/BjyAuthorize/src/BjyAuthorize/Guard/Controller.php‌​:172 I already have some user in my database. How can I use those credentials to authorize a CLI user to run Actions? Edit : Following is the guards array in bjyauthorize.global.php

angular 7 does not ask if to use routing when i create a new project

好久不见. 提交于 2019-12-05 16:20:43
I was formerly using Angular version 6, now I have upgraded to 7. But when I try to create a new project in CLI using ng new [app-name] it just starts without asking if I want to include routing in my project or the styling. P.S: I have the latest version of Angular i.e 7.0.2. veeresh patil ng new {Project-name} command by default creates project without routing. You need to set routing flag as true while creating project as below(by default this routing flag will be false), ng new {Project-name} --routing=true Go through angular documentation for more details ng new --help run this command

Interpret and execute arbitrary Javascript in Linux CLI

99封情书 提交于 2019-12-05 16:18:49
问题 I've been looking for ways to do this for a while but haven't quite been able to find the right way to do it. The task: Execute Javascript from a Linux command line. For example, have the binary or whatever is going to interpret Javascript load up some .js files, then print a value of some variable. More concrete example: I would like to get the final version of this page after Javascript has been interpreted and executed http://www.vureel.com/video/2809/American-Dad. If you look at the page

pass results to another command in redis

。_饼干妹妹 提交于 2019-12-05 16:03:59
Is there a way to pass the return value of one function to another in Redis? Of course, if you're using a language wrapper (like Ruby), it's easy — but what about from the CLI? e.g. something like this, bash style redis 127.0.0.1:6379> keys student* | mget or something like this redis 127.0.0.1:6379> mget(keys student*) keys student* will return a list of keys, but I've no idea how to fetch all the values for those keys. Thoughts? From the CLI, you just have to let the shell do its job. ./redis-cli --raw keys 'student:*' | awk '{printf "get %s\n", $1}' | ./redis-cli --raw Please note you are

Why does Doctrine 2 create ~Entity.php file?

泪湿孤枕 提交于 2019-12-05 16:03:04
When I generate my entities I have a file prefixed with ~ like a backup file or something Is it a bug or you need to manually remove them? From the official documentation in Symfony2 CLI command: $> php app/console help doctrine:generate:entities .... By default, the unmodified version of each entity is backed up and saved (e.g. Product.php~). To prevent this task from creating the backup file, pass the --no-backup option: php app/console doctrine:generate:entities Blog/Entity --no-backup So to summarize, you may add --no-backup option to your command. 来源: https://stackoverflow.com/questions

mv: invalid option — '0'

China☆狼群 提交于 2019-12-05 14:25:37
How can I rename files with "-" in front of the filename, for example: "-0001.jpg" Everyime I try to run: for i in *; do mv "$i" "${i//-/}"; done or: for i in *; do mv "$i" "${i#*-}"; done I got this error: mv: invalid option -- '0' Try `mv --help' for more information. Thanks for any light! mv ./-00008.jpg to/some/where.jpg ^ - start with path... as with most gnu commands, use the -- switch before the filename with the hyphen. it signifies "end of switches". Put a double - before the arguments that can contain "-" in the begin; then there can't be options after --. mv OPTIONS -- ... 来源: https

Send email when error occurs in console command of Symfony2 app

泪湿孤枕 提交于 2019-12-05 14:21:08
How is it possible to send email with log when something wrong in console command? Currently I've configured my app to send emails from web interface and it works correctly. Swiftmailer spool is disabled. My config is: monolog: handlers: main: type: fingers_crossed action_level: critical handler: grouped grouped: type: group members: [streamed, buffered] streamed: type: stream path: "%kernel.logs_dir%/%kernel.environment%.log" level: debug buffered: type: buffer handler: swift swift: type: swift_mailer from_email: info@site.com to_email: username@site.com subject: An Error Occurred! level:

Single dash for argparse long options

不问归期 提交于 2019-12-05 13:18:43
Is it possible to make it so that --longoption is represented as -longoption using argparse? argparse.prefix_chars doesn't work, as it is assumed that the prefix char would be repeated for a long option. I'm thinking perhaps there is a way to turn off short options and allow long options to use a single dash instead of a double dash. Something like this: parser = argparse.ArgumentParser() parser.turn_off_short_opts() Can this be done? If not, what can I use to accomplish this? Single dash long arguments aren't a problem: In [250]: p=argparse.ArgumentParser() In [251]: p.add_argument('

npm package.json bin won't work on Windows

我与影子孤独终老i 提交于 2019-12-05 12:30:56
问题 I am trying to start my cli tool via the package.json bin property. I have the following: ... "name": "mycli", "bin": "./bin/mycli", ... When I open the cmd in the package path and type: "mycli" it says that the command is not recognized. Should I run an npm command? or use the scripts property? am I trying to access the bin property incorrectly? 回答1: Try to specify the name of your cli tool in the bin property, like: "bin": { "mycli": "./bin/mycli" // or "/bin/mycli.js" if it's a .js file }