command-line-interface

A Bash script to upload images to imgur.com automatically asking for new access_token

我是研究僧i 提交于 2019-12-23 01:54:26
问题 I was wondering if there's an already written Bash script which will be capable of uploading images to imgur.com along with automating the process of requesting new access token once it expire. Searching for such a script I found a few which do not support OAuth2: Quoted from Imgur's OAuth2.0 overview The Imgur API uses OAuth 2.0 for authentication. OAuth 2.0 has four steps: registration, authorization, making the request, and getting new access_tokens after the initial one expired .

How to prevent user stopping script by CTRL + Z?

徘徊边缘 提交于 2019-12-22 20:12:08
问题 I want to prevent user to go back to shell_prompt by pressing CTRL + Z from my python command line interpreter script. 回答1: You could write a signal handler for SIGTSTP, which is triggered by Ctrl + Z . Here is an example: import signal def handler(signum, frame): print 'Ctrl+Z pressed, but ignored' signal.signal(signal.SIGTSTP, handler) while True: pass 回答2: The following does the trick on my Linux box: signal.signal(signal.SIGTSTP, signal.SIG_IGN) Here is a complete example: import signal

Python: How to quit CLI when stuck in blocking raw_input?

三世轮回 提交于 2019-12-22 13:53:22
问题 I have a GUI program which should also be controllable via CLI (for monitoring). The CLI is implemented in a while loop using raw_input. If I quit the program via a GUI close button, it hangs in raw_input and does not quit until it gets an input. How can I immediately abort raw_input without entering an input? I run it on WinXP but I want it to be platform independent, it should also work within Eclipse since it is a developer tool. Python version is 2.6. I searched stackoverflow for hours

“sort filename | uniq” does not work on large files

假装没事ソ 提交于 2019-12-22 10:33:23
问题 I can remove duplicate entries from small text files, but not large text files. I have a file that's 4MB. The beginning of the file looks like this: aa aah aahed aahed aahing aahing aahs aahs aal aalii aalii aaliis aaliis ... I want to remove the duplicates. For example, "aahed" shows up twice, and I would only like it to show up once. No matter what one-liner I've tried, the big list will not change. If It type: sort big_list.txt | uniq | less I see: aa aah aahed aahed <-- didn't get rid of

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

拟墨画扇 提交于 2019-12-22 08:55:06
问题 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

How to test stdin for a CLI using rspec

旧巷老猫 提交于 2019-12-22 08:38:27
问题 I'm making a small Ruby program and can't figure out how to write RSpec specs that simulate multiple user command line inputs (the functionality itself works). I think this StackOverflow answer probably covers ground that is closest to where I am, but it's not quite what I need. I am using Thor for the command line interface, but I don't think this is an issue with anything in Thor. The program can read in commands either from a file or the command line, and I've been able to successfully

mail() timeout issue

依然范特西╮ 提交于 2019-12-22 04:01:46
问题 When I execute my email script via browser a timeout fatal error is returned (unless I drastically increase the execution time, then it will run ok, not the solution I'm looking for). The email is sent tho , but it takes forever (5 min. average) to arrive (at my inbox)! (Considering that via command line it works perfectly I think that SMTP at php.ini is certainly well configured.) So this is the code executed by browser request: <?php mail('amatos@example.com', 'test subject', 'test body',

Java Apache CLI OptionBuilder not working as Builder pattern

一个人想着一个人 提交于 2019-12-22 02:51:52
问题 I want to do something like public static final Option job1 = OptionBuilder.hasArg(false) .isRequired(false) .withDescription("description of job1") .create(JOB1); as mentioned How to specify multiple options using apache commons cli? I am using maven dependency as <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli</artifactId> <version>1.1</version> </dependency> as mentioned here - http://mvnrepository.com/artifact/commons-cli/commons-cli/1.1 But I am not able to, compiler

Terminate subprocesses of macOS command line tool in Swift

≯℡__Kan透↙ 提交于 2019-12-22 01:09:10
问题 I'm writing a macOS command line tool in swift which executes shell commands: let process = Process() process.launchPath = "/bin/sleep" process.arguments = ["100"] process.launch() process.waitUntilExit() However, if an interrupt ( CTRL-C ) or a terminate signal gets sent to my program, these shell commands don't get terminated and just continue with their execution. Is there a way to automatically terminate them if my program gets terminated unexpectedly? 回答1: Here is what we did in order to

Proper Measurement of Characters in Pixels

帅比萌擦擦* 提交于 2019-12-22 01:09:05
问题 I'm writing a text box from scratch in order to optimize it for syntax highlighting. However, I need to get the width of characters in pixels, exactly, not the garbage Graphics::MeasureString gives me. I've found a lot of stuff on the web, specifially this, however, none of it seems to work, or does not account for tabs. I need the fastest way to measure the exact dimensions of a character in pixels, and tab spaces. I can't seem to figure this one out... Should mention I'm using C++, CLR/CLI,